Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / dev / network / neptune / global.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: global.fth
4\
5\ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6\
7\ - Do no alter or remove copyright notices
8\
9\ - Redistribution and use of this software in source and binary forms, with
10\ or without modification, are permitted provided that the following
11\ conditions are met:
12\
13\ - Redistribution of source code must retain the above copyright notice,
14\ this list of conditions and the following disclaimer.
15\
16\ - Redistribution in binary form must reproduce the above copyright notice,
17\ this list of conditions and the following disclaimer in the
18\ documentation and/or other materials provided with the distribution.
19\
20\ Neither the name of Sun Microsystems, Inc. or the names of contributors
21\ may be used to endorse or promote products derived from this software
22\ without specific prior written permission.
23\
24\ This software is provided "AS IS," without a warranty of any kind.
25\ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
26\ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
27\ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
28\ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
29\ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
30\ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
31\ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
32\ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
33\ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
34\ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
35\ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
36\
37\ You acknowledge that this software is not designed, licensed or
38\ intended for use in the design, construction, operation or maintenance of
39\ any nuclear facility.
40\
41\ ========== Copyright Header End ============================================
42id: @(#)global.fth 1.1 07/01/23
43purpose:
44copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved
45copyright: Use is subject to license terms.
46
47headerless
48
49\ Register offset definitions
500 value pio
510 value fzc-pio
520 value fzc-mac
530 value xmac0
540 value xpcs
550 value xpcs0
560 value pcs0
570 value xmac1
580 value xpcs1
590 value pcs1
600 value bmac2
610 value pcs2
620 value bmac3
630 value pcs3
640 value esr
650 value mif
660 value fzc-ipp
670 value fflp
680 value fzc-fflp
690 value pio-vaddr
700 value zcp
710 value fzc-zcp
720 value dmc
730 value fzc-dmc
740 value txc
750 value fzc-txc
760 value pio-ldsv
770 value pio-ldgim
780 value pio-imask0
790 value pio-imask1
800 value fzc-prom
810 value fzc-pim
82
83
840 value mactype
850 value portmode
860 value port
870 value chan#
88
89\ 2 different MAC types
900 constant xmac
911 constant bmac
92
93\ Driver specific MAC modes
940 constant normal
953 constant xmac-loopback
964 constant xpcs-loopback
975 constant serdes-ewrap-loopback
986 constant serdes-pad-loopback
997 constant xcvr-loopback
1008 constant 2xgf-ext-loopback \ Neptune 2XGF external loopback
1019 constant qgc-ext-loopback \ Neptune QGC external loopback
102
103\ Many of the registers inside NIU are not accessable to the guest.
104\ They are written to by Hypervisor using a set of APIs as a proxy.
105\ We need to key off this when initialzing Neptune vs. NIU
1060 value niu?
107
1080 constant 1g-copper
1091 constant 1g-fiber
1102 constant 10gig
1113 constant 10g-fiber
1124 constant 10g-copper
113
114false value link-is-up?
115
116\ Ethernet standard requires minimun 46B payload, so the minimun
117\ size of the an Ethernet frame is 60B= 6B dest mac + 6B (src mac)
118\ + 2B (ether-type) + 46B
119d# 60 constant /min-ether-len
120
121d# 18 constant full-header
122d# 18 constant /rx-header
123
124: .bad-mode ( -- ) cmn-warn[ " Bad speed mode" ]cmn-end ;
125: .bad-mactype ( -- ) cmn-warn[ " Bad MAC type" ]cmn-end ;
126
127\ Neptune is a little endian device. The 'rl@' FCode tokenizes into 'x@',
128\ which is a big endian access. We pre-swap the data here so that we read and
129\ write the correct values.
130: swapped-rx@ ( vadr -- x ) rx@ xbflip ;
131: swapped-rl@ ( vadr -- l ) rl@ lbflip ;
132: swapped-rw@ ( vadr -- w ) rw@ wbflip ;
133: swapped-rx! ( x vadr -- ) >r xbflip r> rx! ;
134: swapped-rl! ( l vadr -- ) >r lbflip r> rl! ;
135: swapped-rw! ( l vadr -- ) >r wbflip r> rw! ;
136
137\ Must swap for real hardware.
138alias rx@ swapped-rx@
139alias rl@ swapped-rl@
140alias rw@ swapped-rw@
141alias rx! swapped-rx!
142alias rl! swapped-rl!
143alias rw! swapped-rw!
144
1451 d# 8 lshift constant mpr \ Used by both XMAC and BMAC
146
147: unsupported-port ( -- )
148 cmn-fatal[ " Unsupported port number" ]cmn-end abort
149;
150
151\ Offsets for the two XMACs
152: xmac-offset ( -- offset )
153 port case
154 0 of h# 0 endof
155 1 of h# 6000 endof
156 unsupported-port
157 endcase
158;
159
160\ Offsets for the two XPCSs
161: xpcs-offset ( -- offset )
162 port case
163 0 of h# 0 endof
164 1 of h# 6000 endof
165 unsupported-port
166 endcase
167;
168
169\ Offsets for the two BMACs
170: bmac-offset ( -- offset )
171 port case
172 2 of h# 0 endof
173 3 of h# 4000 endof
174 unsupported-port
175 endcase
176;
177
178\ Offsets for the four PCSs
179: pcs-offset ( -- offset )
180 port case
181 0 of h# 0 endof
182 1 of h# 6000 endof
183 2 of h# a000 endof
184 3 of h# e000 endof
185 endcase
186;
187
188\ RX Message Descriptor Format
189\ Neptune rmd entry only holds the high32 bits of the 44bits address
1904 constant /rmd
1918 constant /rcd \ Rx Completion descriptor is 8 bytes
192
193d# 64 constant #rmds \ Number of Rx Message Descriptors
194 \ Do not use a too small number because
195 \ WRED requires some room for defending
196 \ the interface from attack
197
198\ #rcds/#rmds = (block buff size)/(smallest partition size in the buff)
199\ = 8K/2K = 4, so #rcds = 4 x #rmds
200#rmds 4 * constant #rcds \ Number of Rx Completion Descriptors
201#rmds 4 - constant #rbufs \ #rmds - 4
202
203d# 8192 constant /rbuf \ Size of each RX buffer
204
205\ TX Message Descriptor Format
206
207d# 64 constant #tmds \ # of TX descriptor ring
208d# 8 constant /tmd \ Size of TX descriptor ring entry
209d# 1 constant #tbufs \ Only 1 TX buffer
210d# 2048 constant /tbuf \ Size of TX buffer
211
212\ --- IPP ---
213\ Because the offsets of Neptune's port0 and port1 IPP must be the same
214\ as the N2-NIU's offsets, the four IPP' offsets are as follows,
215\
216: ipp-step ( port -- ipp-offset )
217 case
218 0 of 0 endof
219 1 of h# 8000 endof
220 2 of h# 4000 endof
221 3 of h# c000 endof
222 endcase
223;
224
225\ --- MIF ---
226h# 2.0000 constant ta=10 \ TA field of Clause 45 frame = 10
2271 d# 28 lshift constant op=write
2283 d# 28 lshift constant op=read45 \ Clause45 Read is b11
2292 d# 28 lshift constant op=read22 \ Clause22 Read is b10
2301 d# 30 lshift constant st=cls22
231
232\ --- Rx Errors ---
2330 value rx-dma-err-status \ Rx DMA Rrror status bits
2340 value rdmc-pre-err-status \ Rx DMA Prefetch Error Status bits
2350 value rdmc-sha-err-status \ Rx DMA Shadow Error Status bits
2360 value rx-ctl-dat-fifo-status
2370 value ipp-int-err-status \ IPP Interrupt status
2380 value rx-xmac-err-status \ Rx XMAC
2390 value rx-bmac-err-status \ Rx BMAC
240
241\ --- Tx Errors ---
2420 value tx-dma-err-status
2430 value tx-xmac-err-status
2440 value tx-bmac-err-status
245
246\ --- Do external loopback or not ---
247false value do-ext-loopback?