Ethernet.py revision 13767:85278a98657c
1# Copyright (c) 2015 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder.  You may use the software subject to the license
9# terms below provided that you ensure that this notice is replicated
10# unmodified and in its entirety in all distributions of the software,
11# modified or unmodified, in source code or in binary form.
12#
13# Copyright (c) 2005-2007 The Regents of The University of Michigan
14# All rights reserved.
15#
16# Redistribution and use in source and binary forms, with or without
17# modification, are permitted provided that the following conditions are
18# met: redistributions of source code must retain the above copyright
19# notice, this list of conditions and the following disclaimer;
20# redistributions in binary form must reproduce the above copyright
21# notice, this list of conditions and the following disclaimer in the
22# documentation and/or other materials provided with the distribution;
23# neither the name of the copyright holders nor the names of its
24# contributors may be used to endorse or promote products derived from
25# this software without specific prior written permission.
26#
27# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38#
39# Authors: Nathan Binkert
40
41from m5.defines import buildEnv
42from m5.SimObject import SimObject
43from m5.params import *
44from m5.proxy import *
45from m5.objects.PciDevice import PciDevice
46
47class EtherLink(SimObject):
48    type = 'EtherLink'
49    cxx_header = "dev/net/etherlink.hh"
50    cxx_extra_bases = [ "EtherObject" ]
51    int0 = SlavePort("interface 0")
52    int1 = SlavePort("interface 1")
53    delay = Param.Latency('0us', "packet transmit delay")
54    delay_var = Param.Latency('0ns', "packet transmit delay variability")
55    speed = Param.NetworkBandwidth('1Gbps', "link speed")
56    dump = Param.EtherDump(NULL, "dump object")
57
58class DistEtherLink(SimObject):
59    type = 'DistEtherLink'
60    cxx_header = "dev/net/dist_etherlink.hh"
61    cxx_extra_bases = [ "EtherObject" ]
62    int0 = SlavePort("interface 0")
63    delay = Param.Latency('0us', "packet transmit delay")
64    delay_var = Param.Latency('0ns', "packet transmit delay variability")
65    speed = Param.NetworkBandwidth('1Gbps', "link speed")
66    dump = Param.EtherDump(NULL, "dump object")
67    dist_rank = Param.UInt32('0', "Rank of this gem5 process (dist run)")
68    dist_size = Param.UInt32('1', "Number of gem5 processes (dist run)")
69    sync_start = Param.Latency('5200000000000t', "first dist sync barrier")
70    sync_repeat = Param.Latency('10us', "dist sync barrier repeat")
71    server_name = Param.String('localhost', "Message server name")
72    server_port = Param.UInt32('2200', "Message server port")
73    is_switch = Param.Bool(False, "true if this a link in etherswitch")
74    dist_sync_on_pseudo_op = Param.Bool(False, "Start sync with pseudo_op")
75    num_nodes = Param.UInt32('2', "Number of simulate nodes")
76
77class EtherBus(SimObject):
78    type = 'EtherBus'
79    cxx_header = "dev/net/etherbus.hh"
80    cxx_extra_bases = [ "EtherObject" ]
81    loopback = Param.Bool(True, "send packet back to the sending interface")
82    dump = Param.EtherDump(NULL, "dump object")
83    speed = Param.NetworkBandwidth('100Mbps', "bus speed in bits per second")
84
85class EtherSwitch(SimObject):
86    type = 'EtherSwitch'
87    cxx_header = "dev/net/etherswitch.hh"
88    cxx_extra_bases = [ "EtherObject" ]
89    dump = Param.EtherDump(NULL, "dump object")
90    fabric_speed = Param.NetworkBandwidth('10Gbps', "switch fabric speed in bits "
91                                          "per second")
92    interface = VectorMasterPort("Ethernet Interface")
93    output_buffer_size = Param.MemorySize('1MB', "size of output port buffers")
94    delay = Param.Latency('0us', "packet transmit delay")
95    delay_var = Param.Latency('0ns', "packet transmit delay variability")
96    time_to_live = Param.Latency('10ms', "time to live of MAC address maping")
97
98class EtherTapBase(SimObject):
99    type = 'EtherTapBase'
100    abstract = True
101    cxx_header = "dev/net/ethertap.hh"
102    cxx_extra_bases = [ "EtherObject" ]
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    cxx_extra_bases = [ "EtherObject" ]
131    interface = MasterPort("Ethernet Interface")
132
133class IGbE(EtherDevice):
134    # Base class for two IGbE adapters listed above
135    type = 'IGbE'
136    cxx_header = "dev/net/i8254xGBe.hh"
137    hardware_address = Param.EthernetAddr(NextEthernetAddr,
138        "Ethernet Hardware Address")
139    rx_fifo_size = Param.MemorySize('384kB', "Size of the rx FIFO")
140    tx_fifo_size = Param.MemorySize('384kB', "Size of the tx FIFO")
141    rx_desc_cache_size = Param.Int(64,
142        "Number of enteries in the rx descriptor cache")
143    tx_desc_cache_size = Param.Int(64,
144        "Number of enteries in the rx descriptor cache")
145    VendorID = 0x8086
146    SubsystemID = 0x1008
147    SubsystemVendorID = 0x8086
148    Status = 0x0000
149    SubClassCode = 0x00
150    ClassCode = 0x02
151    ProgIF = 0x00
152    BAR0 = 0x00000000
153    BAR1 = 0x00000000
154    BAR2 = 0x00000000
155    BAR3 = 0x00000000
156    BAR4 = 0x00000000
157    BAR5 = 0x00000000
158    MaximumLatency = 0x00
159    MinimumGrant = 0xff
160    InterruptLine = 0x1e
161    InterruptPin = 0x01
162    BAR0Size = '128kB'
163    wb_delay = Param.Latency('10ns', "delay before desc writeback occurs")
164    fetch_delay = Param.Latency('10ns', "delay before desc fetch occurs")
165    fetch_comp_delay = Param.Latency('10ns', "delay after desc fetch occurs")
166    wb_comp_delay = Param.Latency('10ns', "delay after desc wb occurs")
167    tx_read_delay = Param.Latency('0ns', "delay after tx dma read")
168    rx_write_delay = Param.Latency('0ns', "delay after rx dma read")
169    phy_pid = Param.UInt16("Phy PID that corresponds to device ID")
170    phy_epid = Param.UInt16("Phy EPID that corresponds to device ID")
171
172class IGbE_e1000(IGbE):
173    # Older Intel 8254x based gigabit ethernet adapter
174    # Uses Intel e1000 driver
175    DeviceID = 0x1075
176    phy_pid = 0x02A8
177    phy_epid = 0x0380
178
179class IGbE_igb(IGbE):
180    # Newer Intel 8257x based gigabit ethernet adapter
181    # Uses Intel igb driver and in theory supports packet splitting and LRO
182    DeviceID = 0x10C9
183    phy_pid = 0x0141
184    phy_epid = 0x0CC0
185
186class EtherDevBase(EtherDevice):
187    type = 'EtherDevBase'
188    abstract = True
189    cxx_header = "dev/net/etherdevice.hh"
190
191    hardware_address = Param.EthernetAddr(NextEthernetAddr,
192        "Ethernet Hardware Address")
193
194    dma_read_delay = Param.Latency('0us', "fixed delay for dma reads")
195    dma_read_factor = Param.Latency('0us', "multiplier for dma reads")
196    dma_write_delay = Param.Latency('0us', "fixed delay for dma writes")
197    dma_write_factor = Param.Latency('0us', "multiplier for dma writes")
198
199    rx_delay = Param.Latency('1us', "Receive Delay")
200    tx_delay = Param.Latency('1us', "Transmit Delay")
201    rx_fifo_size = Param.MemorySize('512kB', "max size of rx fifo")
202    tx_fifo_size = Param.MemorySize('512kB', "max size of tx fifo")
203
204    rx_filter = Param.Bool(True, "Enable Receive Filter")
205    intr_delay = Param.Latency('10us', "Interrupt propagation delay")
206    rx_thread = Param.Bool(False, "dedicated kernel thread for transmit")
207    tx_thread = Param.Bool(False, "dedicated kernel threads for receive")
208    rss = Param.Bool(False, "Receive Side Scaling")
209
210class NSGigE(EtherDevBase):
211    type = 'NSGigE'
212    cxx_header = "dev/net/ns_gige.hh"
213
214    dma_data_free = Param.Bool(False, "DMA of Data is free")
215    dma_desc_free = Param.Bool(False, "DMA of Descriptors is free")
216    dma_no_allocate = Param.Bool(True, "Should we allocate cache on read")
217
218    VendorID = 0x100B
219    DeviceID = 0x0022
220    Status = 0x0290
221    SubClassCode = 0x00
222    ClassCode = 0x02
223    ProgIF = 0x00
224    BAR0 = 0x00000001
225    BAR1 = 0x00000000
226    BAR2 = 0x00000000
227    BAR3 = 0x00000000
228    BAR4 = 0x00000000
229    BAR5 = 0x00000000
230    MaximumLatency = 0x34
231    MinimumGrant = 0xb0
232    InterruptLine = 0x1e
233    InterruptPin = 0x01
234    BAR0Size = '256B'
235    BAR1Size = '4kB'
236
237
238
239class Sinic(EtherDevBase):
240    type = 'Sinic'
241    cxx_class = 'Sinic::Device'
242    cxx_header = "dev/net/sinic.hh"
243
244    rx_max_copy = Param.MemorySize('1514B', "rx max copy")
245    tx_max_copy = Param.MemorySize('16kB', "tx max copy")
246    rx_max_intr = Param.UInt32(10, "max rx packets per interrupt")
247    rx_fifo_threshold = Param.MemorySize('384kB', "rx fifo high threshold")
248    rx_fifo_low_mark = Param.MemorySize('128kB', "rx fifo low threshold")
249    tx_fifo_high_mark = Param.MemorySize('384kB', "tx fifo high threshold")
250    tx_fifo_threshold = Param.MemorySize('128kB', "tx fifo low threshold")
251    virtual_count = Param.UInt32(1, "Virtualized SINIC")
252    zero_copy_size = Param.UInt32(64, "Bytes to copy if below threshold")
253    zero_copy_threshold = Param.UInt32(256,
254        "Only zero copy above this threshold")
255    zero_copy = Param.Bool(False, "Zero copy receive")
256    delay_copy = Param.Bool(False, "Delayed copy transmit")
257    virtual_addr = Param.Bool(False, "Virtual addressing")
258
259    VendorID = 0x1291
260    DeviceID = 0x1293
261    Status = 0x0290
262    SubClassCode = 0x00
263    ClassCode = 0x02
264    ProgIF = 0x00
265    BAR0 = 0x00000000
266    BAR1 = 0x00000000
267    BAR2 = 0x00000000
268    BAR3 = 0x00000000
269    BAR4 = 0x00000000
270    BAR5 = 0x00000000
271    MaximumLatency = 0x34
272    MinimumGrant = 0xb0
273    InterruptLine = 0x1e
274    InterruptPin = 0x01
275    BAR0Size = '64kB'
276
277
278