Ethernet.py revision 12054:ab04045965d1
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.SimObject import SimObject
42from m5.params import *
43from m5.proxy import *
44from PciDevice import PciDevice
45
46class EtherObject(SimObject):
47    type = 'EtherObject'
48    abstract = True
49    cxx_header = "dev/net/etherobject.hh"
50
51class EtherLink(EtherObject):
52    type = 'EtherLink'
53    cxx_header = "dev/net/etherlink.hh"
54    int0 = SlavePort("interface 0")
55    int1 = SlavePort("interface 1")
56    delay = Param.Latency('0us', "packet transmit delay")
57    delay_var = Param.Latency('0ns', "packet transmit delay variability")
58    speed = Param.NetworkBandwidth('1Gbps', "link speed")
59    dump = Param.EtherDump(NULL, "dump object")
60
61class DistEtherLink(EtherObject):
62    type = 'DistEtherLink'
63    cxx_header = "dev/net/dist_etherlink.hh"
64    int0 = SlavePort("interface 0")
65    delay = Param.Latency('0us', "packet transmit delay")
66    delay_var = Param.Latency('0ns', "packet transmit delay variability")
67    speed = Param.NetworkBandwidth('1Gbps', "link speed")
68    dump = Param.EtherDump(NULL, "dump object")
69    dist_rank = Param.UInt32('0', "Rank of this gem5 process (dist run)")
70    dist_size = Param.UInt32('1', "Number of gem5 processes (dist run)")
71    sync_start = Param.Latency('5200000000000t', "first dist sync barrier")
72    sync_repeat = Param.Latency('10us', "dist sync barrier repeat")
73    server_name = Param.String('localhost', "Message server name")
74    server_port = Param.UInt32('2200', "Message server port")
75    is_switch = Param.Bool(False, "true if this a link in etherswitch")
76    dist_sync_on_pseudo_op = Param.Bool(False, "Start sync with pseudo_op")
77    num_nodes = Param.UInt32('2', "Number of simulate nodes")
78
79class EtherBus(EtherObject):
80    type = 'EtherBus'
81    cxx_header = "dev/net/etherbus.hh"
82    loopback = Param.Bool(True, "send packet back to the sending interface")
83    dump = Param.EtherDump(NULL, "dump object")
84    speed = Param.NetworkBandwidth('100Mbps', "bus speed in bits per second")
85
86class EtherSwitch(EtherObject):
87    type = 'EtherSwitch'
88    cxx_header = "dev/net/etherswitch.hh"
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 EtherTapStub(EtherObject):
99    type = 'EtherTapStub'
100    cxx_header = "dev/net/ethertap.hh"
101    bufsz = Param.Int(10000, "tap buffer size")
102    dump = Param.EtherDump(NULL, "dump object")
103    port = Param.UInt16(3500, "Port helper should send packets to")
104    tap = SlavePort("Ethernet interface to gem5's network")
105
106class EtherDump(SimObject):
107    type = 'EtherDump'
108    cxx_header = "dev/net/etherdump.hh"
109    file = Param.String("dump file")
110    maxlen = Param.Int(96, "max portion of packet data to dump")
111
112class EtherDevice(PciDevice):
113    type = 'EtherDevice'
114    abstract = True
115    cxx_header = "dev/net/etherdevice.hh"
116    interface = MasterPort("Ethernet Interface")
117
118class IGbE(EtherDevice):
119    # Base class for two IGbE adapters listed above
120    type = 'IGbE'
121    cxx_header = "dev/net/i8254xGBe.hh"
122    hardware_address = Param.EthernetAddr(NextEthernetAddr,
123        "Ethernet Hardware Address")
124    rx_fifo_size = Param.MemorySize('384kB', "Size of the rx FIFO")
125    tx_fifo_size = Param.MemorySize('384kB', "Size of the tx FIFO")
126    rx_desc_cache_size = Param.Int(64,
127        "Number of enteries in the rx descriptor cache")
128    tx_desc_cache_size = Param.Int(64,
129        "Number of enteries in the rx descriptor cache")
130    VendorID = 0x8086
131    SubsystemID = 0x1008
132    SubsystemVendorID = 0x8086
133    Status = 0x0000
134    SubClassCode = 0x00
135    ClassCode = 0x02
136    ProgIF = 0x00
137    BAR0 = 0x00000000
138    BAR1 = 0x00000000
139    BAR2 = 0x00000000
140    BAR3 = 0x00000000
141    BAR4 = 0x00000000
142    BAR5 = 0x00000000
143    MaximumLatency = 0x00
144    MinimumGrant = 0xff
145    InterruptLine = 0x1e
146    InterruptPin = 0x01
147    BAR0Size = '128kB'
148    wb_delay = Param.Latency('10ns', "delay before desc writeback occurs")
149    fetch_delay = Param.Latency('10ns', "delay before desc fetch occurs")
150    fetch_comp_delay = Param.Latency('10ns', "delay after desc fetch occurs")
151    wb_comp_delay = Param.Latency('10ns', "delay after desc wb occurs")
152    tx_read_delay = Param.Latency('0ns', "delay after tx dma read")
153    rx_write_delay = Param.Latency('0ns', "delay after rx dma read")
154    phy_pid = Param.UInt16("Phy PID that corresponds to device ID")
155    phy_epid = Param.UInt16("Phy EPID that corresponds to device ID")
156
157class IGbE_e1000(IGbE):
158    # Older Intel 8254x based gigabit ethernet adapter
159    # Uses Intel e1000 driver
160    DeviceID = 0x1075
161    phy_pid = 0x02A8
162    phy_epid = 0x0380
163
164class IGbE_igb(IGbE):
165    # Newer Intel 8257x based gigabit ethernet adapter
166    # Uses Intel igb driver and in theory supports packet splitting and LRO
167    DeviceID = 0x10C9
168    phy_pid = 0x0141
169    phy_epid = 0x0CC0
170
171class EtherDevBase(EtherDevice):
172    type = 'EtherDevBase'
173    abstract = True
174    cxx_header = "dev/net/etherdevice.hh"
175
176    hardware_address = Param.EthernetAddr(NextEthernetAddr,
177        "Ethernet Hardware Address")
178
179    dma_read_delay = Param.Latency('0us', "fixed delay for dma reads")
180    dma_read_factor = Param.Latency('0us', "multiplier for dma reads")
181    dma_write_delay = Param.Latency('0us', "fixed delay for dma writes")
182    dma_write_factor = Param.Latency('0us', "multiplier for dma writes")
183
184    rx_delay = Param.Latency('1us', "Receive Delay")
185    tx_delay = Param.Latency('1us', "Transmit Delay")
186    rx_fifo_size = Param.MemorySize('512kB', "max size of rx fifo")
187    tx_fifo_size = Param.MemorySize('512kB', "max size of tx fifo")
188
189    rx_filter = Param.Bool(True, "Enable Receive Filter")
190    intr_delay = Param.Latency('10us', "Interrupt propagation delay")
191    rx_thread = Param.Bool(False, "dedicated kernel thread for transmit")
192    tx_thread = Param.Bool(False, "dedicated kernel threads for receive")
193    rss = Param.Bool(False, "Receive Side Scaling")
194
195class NSGigE(EtherDevBase):
196    type = 'NSGigE'
197    cxx_header = "dev/net/ns_gige.hh"
198
199    dma_data_free = Param.Bool(False, "DMA of Data is free")
200    dma_desc_free = Param.Bool(False, "DMA of Descriptors is free")
201    dma_no_allocate = Param.Bool(True, "Should we allocate cache on read")
202
203    VendorID = 0x100B
204    DeviceID = 0x0022
205    Status = 0x0290
206    SubClassCode = 0x00
207    ClassCode = 0x02
208    ProgIF = 0x00
209    BAR0 = 0x00000001
210    BAR1 = 0x00000000
211    BAR2 = 0x00000000
212    BAR3 = 0x00000000
213    BAR4 = 0x00000000
214    BAR5 = 0x00000000
215    MaximumLatency = 0x34
216    MinimumGrant = 0xb0
217    InterruptLine = 0x1e
218    InterruptPin = 0x01
219    BAR0Size = '256B'
220    BAR1Size = '4kB'
221
222
223
224class Sinic(EtherDevBase):
225    type = 'Sinic'
226    cxx_class = 'Sinic::Device'
227    cxx_header = "dev/net/sinic.hh"
228
229    rx_max_copy = Param.MemorySize('1514B', "rx max copy")
230    tx_max_copy = Param.MemorySize('16kB', "tx max copy")
231    rx_max_intr = Param.UInt32(10, "max rx packets per interrupt")
232    rx_fifo_threshold = Param.MemorySize('384kB', "rx fifo high threshold")
233    rx_fifo_low_mark = Param.MemorySize('128kB', "rx fifo low threshold")
234    tx_fifo_high_mark = Param.MemorySize('384kB', "tx fifo high threshold")
235    tx_fifo_threshold = Param.MemorySize('128kB', "tx fifo low threshold")
236    virtual_count = Param.UInt32(1, "Virtualized SINIC")
237    zero_copy_size = Param.UInt32(64, "Bytes to copy if below threshold")
238    zero_copy_threshold = Param.UInt32(256,
239        "Only zero copy above this threshold")
240    zero_copy = Param.Bool(False, "Zero copy receive")
241    delay_copy = Param.Bool(False, "Delayed copy transmit")
242    virtual_addr = Param.Bool(False, "Virtual addressing")
243
244    VendorID = 0x1291
245    DeviceID = 0x1293
246    Status = 0x0290
247    SubClassCode = 0x00
248    ClassCode = 0x02
249    ProgIF = 0x00
250    BAR0 = 0x00000000
251    BAR1 = 0x00000000
252    BAR2 = 0x00000000
253    BAR3 = 0x00000000
254    BAR4 = 0x00000000
255    BAR5 = 0x00000000
256    MaximumLatency = 0x34
257    MinimumGrant = 0xb0
258    InterruptLine = 0x1e
259    InterruptPin = 0x01
260    BAR0Size = '64kB'
261
262
263