Ethernet.py revision 5763
1# Copyright (c) 2005-2007 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright
9# notice, this list of conditions and the following disclaimer in the
10# documentation and/or other materials provided with the distribution;
11# neither the name of the copyright holders nor the names of its
12# contributors may be used to endorse or promote products derived from
13# this software without specific prior written permission.
14#
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26#
27# Authors: Nathan Binkert
28
29from m5.SimObject import SimObject
30from m5.params import *
31from m5.proxy import *
32from Pci import PciDevice
33
34class EtherObject(SimObject):
35    type = 'EtherObject'
36    abstract = True
37
38class EtherLink(EtherObject):
39    type = 'EtherLink'
40    int0 = Port("interface 0")
41    int1 = Port("interface 1")
42    delay = Param.Latency('0us', "packet transmit delay")
43    delay_var = Param.Latency('0ns', "packet transmit delay variability")
44    speed = Param.NetworkBandwidth('1Gbps', "link speed")
45    dump = Param.EtherDump(NULL, "dump object")
46
47class EtherBus(EtherObject):
48    type = 'EtherBus'
49    loopback = Param.Bool(True, "send packet back to the sending interface")
50    dump = Param.EtherDump(NULL, "dump object")
51    speed = Param.NetworkBandwidth('100Mbps', "bus speed in bits per second")
52
53class EtherTap(EtherObject):
54    type = 'EtherTap'
55    bufsz = Param.Int(10000, "tap buffer size")
56    dump = Param.EtherDump(NULL, "dump object")
57    port = Param.UInt16(3500, "tap port")
58
59class EtherDump(SimObject):
60    type = 'EtherDump'
61    file = Param.String("dump file")
62    maxlen = Param.Int(96, "max portion of packet data to dump")
63
64class EtherDevice(PciDevice):
65    type = 'EtherDevice'
66    abstract = True
67    interface = Port("Ethernet Interrface")
68
69class IGbE(EtherDevice):
70    # Base class for two IGbE adapters listed above
71    type = 'IGbE'
72    #abstract = True
73    hardware_address = Param.EthernetAddr(NextEthernetAddr,
74        "Ethernet Hardware Address")
75    use_flow_control = Param.Bool(False,
76        "Should we use xon/xoff flow contorl (UNIMPLEMENTD)")
77    rx_fifo_size = Param.MemorySize('384kB', "Size of the rx FIFO")
78    tx_fifo_size = Param.MemorySize('384kB', "Size of the tx FIFO")
79    rx_desc_cache_size = Param.Int(64,
80        "Number of enteries in the rx descriptor cache")
81    tx_desc_cache_size = Param.Int(64,
82        "Number of enteries in the rx descriptor cache")
83    clock = Param.Clock('500MHz', "Clock speed of the device")
84    VendorID = 0x8086
85    SubsystemID = 0x1008
86    SubsystemVendorID = 0x8086
87    Status = 0x0000
88    SubClassCode = 0x00
89    ClassCode = 0x02
90    ProgIF = 0x00
91    BAR0 = 0x00000000
92    BAR1 = 0x00000000
93    BAR2 = 0x00000000
94    BAR3 = 0x00000000
95    BAR4 = 0x00000000
96    BAR5 = 0x00000000
97    MaximumLatency = 0x00
98    MinimumGrant = 0xff
99    InterruptLine = 0x1e
100    InterruptPin = 0x01
101    BAR0Size = '128kB'
102    wb_delay = Param.Latency('10ns', "delay before desc writeback occurs")
103    fetch_delay = Param.Latency('10ns', "delay before desc fetch occurs")
104    fetch_comp_delay = Param.Latency('10ns', "delay after desc fetch occurs")
105    wb_comp_delay = Param.Latency('10ns', "delay after desc wb occurs")
106    tx_read_delay = Param.Latency('0ns', "delay after tx dma read")
107    rx_write_delay = Param.Latency('0ns', "delay after rx dma read")
108    is8257 = Param.Bool("Select between and 8254x and 8257x device")
109
110
111class IGbE_e1000(IGbE):
112    # Older Intel 8254x based gigabit ethernet adapter
113    # Uses Intel e1000 driver
114    DeviceID = 0x1075
115    is8257 = False
116
117class IGbE_igb(IGbE):
118    # Newer Intel 8257x based gigabit ethernet adapter
119    # Uses Intel igb driver and in theory supports packet splitting and LRO
120    DeviceID = 0x10C9
121    is8257 = True
122
123class EtherDevBase(EtherDevice):
124    type = 'EtherDevBase'
125    abstract = True
126    hardware_address = Param.EthernetAddr(NextEthernetAddr,
127        "Ethernet Hardware Address")
128
129    clock = Param.Clock('0ns', "State machine processor frequency")
130
131    dma_read_delay = Param.Latency('0us', "fixed delay for dma reads")
132    dma_read_factor = Param.Latency('0us', "multiplier for dma reads")
133    dma_write_delay = Param.Latency('0us', "fixed delay for dma writes")
134    dma_write_factor = Param.Latency('0us', "multiplier for dma writes")
135
136    rx_delay = Param.Latency('1us', "Receive Delay")
137    tx_delay = Param.Latency('1us', "Transmit Delay")
138    rx_fifo_size = Param.MemorySize('512kB', "max size of rx fifo")
139    tx_fifo_size = Param.MemorySize('512kB', "max size of tx fifo")
140
141    rx_filter = Param.Bool(True, "Enable Receive Filter")
142    intr_delay = Param.Latency('10us', "Interrupt propagation delay")
143    rx_thread = Param.Bool(False, "dedicated kernel thread for transmit")
144    tx_thread = Param.Bool(False, "dedicated kernel threads for receive")
145    rss = Param.Bool(False, "Receive Side Scaling")
146
147class NSGigE(EtherDevBase):
148    type = 'NSGigE'
149
150    dma_data_free = Param.Bool(False, "DMA of Data is free")
151    dma_desc_free = Param.Bool(False, "DMA of Descriptors is free")
152    dma_no_allocate = Param.Bool(True, "Should we allocate cache on read")
153
154    VendorID = 0x100B
155    DeviceID = 0x0022
156    Status = 0x0290
157    SubClassCode = 0x00
158    ClassCode = 0x02
159    ProgIF = 0x00
160    BAR0 = 0x00000001
161    BAR1 = 0x00000000
162    BAR2 = 0x00000000
163    BAR3 = 0x00000000
164    BAR4 = 0x00000000
165    BAR5 = 0x00000000
166    MaximumLatency = 0x34
167    MinimumGrant = 0xb0
168    InterruptLine = 0x1e
169    InterruptPin = 0x01
170    BAR0Size = '256B'
171    BAR1Size = '4kB'
172
173
174
175class Sinic(EtherDevBase):
176    type = 'Sinic'
177    cxx_class = 'Sinic::Device'
178
179    rx_max_copy = Param.MemorySize('1514B', "rx max copy")
180    tx_max_copy = Param.MemorySize('16kB', "tx max copy")
181    rx_max_intr = Param.UInt32(10, "max rx packets per interrupt")
182    rx_fifo_threshold = Param.MemorySize('384kB', "rx fifo high threshold")
183    rx_fifo_low_mark = Param.MemorySize('128kB', "rx fifo low threshold")
184    tx_fifo_high_mark = Param.MemorySize('384kB', "tx fifo high threshold")
185    tx_fifo_threshold = Param.MemorySize('128kB', "tx fifo low threshold")
186    virtual_count = Param.UInt32(1, "Virtualized SINIC")
187    zero_copy_size = Param.UInt32(64, "Bytes to copy if below threshold")
188    zero_copy_threshold = Param.UInt32(256,
189        "Only zero copy above this threshold")
190    zero_copy = Param.Bool(False, "Zero copy receive")
191    delay_copy = Param.Bool(False, "Delayed copy transmit")
192    virtual_addr = Param.Bool(False, "Virtual addressing")
193
194    VendorID = 0x1291
195    DeviceID = 0x1293
196    Status = 0x0290
197    SubClassCode = 0x00
198    ClassCode = 0x02
199    ProgIF = 0x00
200    BAR0 = 0x00000000
201    BAR1 = 0x00000000
202    BAR2 = 0x00000000
203    BAR3 = 0x00000000
204    BAR4 = 0x00000000
205    BAR5 = 0x00000000
206    MaximumLatency = 0x34
207    MinimumGrant = 0xb0
208    InterruptLine = 0x1e
209    InterruptPin = 0x01
210    BAR0Size = '64kB'
211
212
213