Commit | Line | Data |
---|---|---|
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 ============================================ | |
42 | id: @(#)global.fth 1.1 07/01/23 | |
43 | purpose: | |
44 | copyright: Copyright 2007 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | headerless | |
48 | ||
49 | \ Register offset definitions | |
50 | 0 value pio | |
51 | 0 value fzc-pio | |
52 | 0 value fzc-mac | |
53 | 0 value xmac0 | |
54 | 0 value xpcs | |
55 | 0 value xpcs0 | |
56 | 0 value pcs0 | |
57 | 0 value xmac1 | |
58 | 0 value xpcs1 | |
59 | 0 value pcs1 | |
60 | 0 value bmac2 | |
61 | 0 value pcs2 | |
62 | 0 value bmac3 | |
63 | 0 value pcs3 | |
64 | 0 value esr | |
65 | 0 value mif | |
66 | 0 value fzc-ipp | |
67 | 0 value fflp | |
68 | 0 value fzc-fflp | |
69 | 0 value pio-vaddr | |
70 | 0 value zcp | |
71 | 0 value fzc-zcp | |
72 | 0 value dmc | |
73 | 0 value fzc-dmc | |
74 | 0 value txc | |
75 | 0 value fzc-txc | |
76 | 0 value pio-ldsv | |
77 | 0 value pio-ldgim | |
78 | 0 value pio-imask0 | |
79 | 0 value pio-imask1 | |
80 | 0 value fzc-prom | |
81 | 0 value fzc-pim | |
82 | ||
83 | ||
84 | 0 value mactype | |
85 | 0 value portmode | |
86 | 0 value port | |
87 | 0 value chan# | |
88 | ||
89 | \ 2 different MAC types | |
90 | 0 constant xmac | |
91 | 1 constant bmac | |
92 | ||
93 | \ Driver specific MAC modes | |
94 | 0 constant normal | |
95 | 3 constant xmac-loopback | |
96 | 4 constant xpcs-loopback | |
97 | 5 constant serdes-ewrap-loopback | |
98 | 6 constant serdes-pad-loopback | |
99 | 7 constant xcvr-loopback | |
100 | 8 constant 2xgf-ext-loopback \ Neptune 2XGF external loopback | |
101 | 9 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 | |
106 | 0 value niu? | |
107 | ||
108 | 0 constant 1g-copper | |
109 | 1 constant 1g-fiber | |
110 | 2 constant 10gig | |
111 | 3 constant 10g-fiber | |
112 | 4 constant 10g-copper | |
113 | ||
114 | false 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 | |
119 | d# 60 constant /min-ether-len | |
120 | ||
121 | d# 18 constant full-header | |
122 | d# 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. | |
138 | alias rx@ swapped-rx@ | |
139 | alias rl@ swapped-rl@ | |
140 | alias rw@ swapped-rw@ | |
141 | alias rx! swapped-rx! | |
142 | alias rl! swapped-rl! | |
143 | alias rw! swapped-rw! | |
144 | ||
145 | 1 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 | |
190 | 4 constant /rmd | |
191 | 8 constant /rcd \ Rx Completion descriptor is 8 bytes | |
192 | ||
193 | d# 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 | ||
203 | d# 8192 constant /rbuf \ Size of each RX buffer | |
204 | ||
205 | \ TX Message Descriptor Format | |
206 | ||
207 | d# 64 constant #tmds \ # of TX descriptor ring | |
208 | d# 8 constant /tmd \ Size of TX descriptor ring entry | |
209 | d# 1 constant #tbufs \ Only 1 TX buffer | |
210 | d# 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 --- | |
226 | h# 2.0000 constant ta=10 \ TA field of Clause 45 frame = 10 | |
227 | 1 d# 28 lshift constant op=write | |
228 | 3 d# 28 lshift constant op=read45 \ Clause45 Read is b11 | |
229 | 2 d# 28 lshift constant op=read22 \ Clause22 Read is b10 | |
230 | 1 d# 30 lshift constant st=cls22 | |
231 | ||
232 | \ --- Rx Errors --- | |
233 | 0 value rx-dma-err-status \ Rx DMA Rrror status bits | |
234 | 0 value rdmc-pre-err-status \ Rx DMA Prefetch Error Status bits | |
235 | 0 value rdmc-sha-err-status \ Rx DMA Shadow Error Status bits | |
236 | 0 value rx-ctl-dat-fifo-status | |
237 | 0 value ipp-int-err-status \ IPP Interrupt status | |
238 | 0 value rx-xmac-err-status \ Rx XMAC | |
239 | 0 value rx-bmac-err-status \ Rx BMAC | |
240 | ||
241 | \ --- Tx Errors --- | |
242 | 0 value tx-dma-err-status | |
243 | 0 value tx-xmac-err-status | |
244 | 0 value tx-bmac-err-status | |
245 | ||
246 | \ --- Do external loopback or not --- | |
247 | false value do-ext-loopback? |