interplane.Get Omega
Read in your language

rtl8127-omega

aien-dev/rtl8127-omega

Brought by drakestapleton

branch main Branches Tags History

rtl8127-omega / om / rtl8127 / test / driver.om

339 lines · 7637 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note driver.om: the RTL8127 driver core (rtl8127.om) against the software chip (model.om).
3note Prints one "FAIL id" line per failed check and a final "RTL8127_OMEGA_MODEL: PASS checks=N" or "...: FAIL ...". Exit 0 only on PASS.
4note Ported in spirit from native/net/tests/rtl8127_test.c (aien-dev/aienux PR 450): same chip-model idea, not line for line.
5
6global tt ulong 4
7global pb uchar 32
8text tpass "RTL8127_OMEGA_MODEL: PASS checks="
9text tfail "RTL8127_OMEGA_MODEL: FAIL checks="
10text tfl "FAIL "
11text tfl2 " failures="
12text tnl "\n"
13
14const DMA ulong 296352743424
15
16fn pnum v ulong to void
17b = new uchar 24 0
18n = ulong 24
19x = v
20if eq x 0
21n = sub n 1
22put b n 48
23end
24while ne x 0 bound 20
25n = sub n 1
26put b n uchar add 48 rem x 10
27x = div x 10
28end
29w = write 1 b n sub 24 n
30end
31
32fn chk id ulong c bool to void
33put tt 0 add get tt 0 1
34if not c
35put tt 1 add get tt 1 1
36w = write 1 tfl 0 5
37pnum id
38w = write 1 tnl 0 1
39end
40end
41
42fn fill n ulong seed ulong to void
43for i ulong n
44put fbuf i uchar and add mul seed 31 mul i 7 255
45end
46end
47
48fn up to ulong
49mchip DMA
50ret rtlinit DMA
51end
52
53fn tinit to void
54e = up
55chk 101 eq e 0
56chk 102 eq get rs S_READY 1
57chk 103 eq get rs S_BROKE 0
58chk 104 eq get rs S_MCFG 2
59chk 105 eq get rs S_ICUNK 0
60chk 106 eq get rs add S_MAC0 0 72
61chk 107 and eq get rs add S_MAC0 1 17 eq get rs add S_MAC0 2 34
62chk 108 and eq get rs add S_MAC0 3 51 eq get rs add S_MAC0 4 68
63chk 109 and eq get rs add S_MAC0 5 85 eq get rs S_MACSRC MS_BACK
64chk 110 eq mget MAC0 4 857870664
65chk 111 eq mget MAC4 2 21828
66chk 112 and eq get mc M_MACU 2 eq get mc M_MACL 0
67chk 113 eq and mget CFG9346 1 UNLOCK 0
68chk 114 eq mring TNPDSLO add DMA OFFTXD
69chk 115 eq mring RDSARLO add DMA OFFRXD
70chk 116 eq get mc M_ENBR 0
71chk 117 eq mget TCR 4 TCRVAL
72chk 118 eq mget RCR 4 or or RCRCHIP RCRBCST RCRMYPH
73chk 119 eq mget RMS 2 or RMSVAL RMSVLAN
74chk 120 ne and mget TXNOCLO 1 4 0
75chk 121 eq get mocp div OCPFMT 2 32769
76chk 122 eq mget RSSCTRL 4 0
77chk 123 eq mget QNUMCTL 2 256
78chk 124 eq and mget RXDTYPE 1 2 0
79chk 125 eq and mget RXDVGATE 1 8 0
80chk 126 eq mget IMR0 4 0
81chk 127 eq mget ISR0 4 0
82chk 128 eq and mget INTCFG0 1 97 0
83chk 129 eq mget CHIPCMD 1 or CMDTXEN CMDRXEN
84chk 130 eq and mget MCUCMD 1 MCUOOB 0
85end
86
87fn tinit2 to void
88chk 131 eq get mocp div ulong 49340 2 255
89chk 143 eq get mocp div ulong 49322 2 2000
90chk 132 eq get mocp div ulong 49318 2 437
91chk 144 eq get mocp div ulong 49182 2 21845
92chk 133 eq get mphy div ulong 41984 2 4096
93chk 145 eq get rs S_PHYST 3
94chk 134 eq and mget PMCH 1 192 192
95chk 135 eq get mc M_RSTS 2
96chk 136 eq get rs S_WTO 0
97for i ulong RXN
98d = add OFFRXD mul i 16
99o1 = mrd32 d
100chk 137 and ne and o1 DOWN 0 eq and o1 RXLEN RXBUF
101chk 138 eq ne and o1 DEOR 0 eq i sub RXN 1
102a = or mrd32 add d 8 shl mrd32 add d 12 32
103chk 139 eq a add add DMA OFFRXB mul i STRIDE
104end
105for i ulong TXN
106o1 = mrd32 mul i 32
107chk 140 eq ne and o1 DEOR 0 eq i sub TXN 1
108end
109l = rtllink
110chk 141 and eq l 1 eq get rs S_MBPS 10000
111chk 142 eq get mc M_DMAF 0
112end
113
114fn trefuse to void
115mchip DMA
116put mc M_ABS 1
117chk 201 eq rtlinit DMA E_ABSENT
118chk 202 eq get mc M_WRS 0
119fill 20 1
120chk 203 eq rtltx 20 E_NOTRDY
121mchip DMA
122mput TCR 4 1409286144
123chk 204 eq rtlinit DMA E_CHIP
124chk 205 eq get mc M_WRS 0
125chk 206 and eq rtlstop E_NOTRDY eq get mc M_WRS 0
126mchip DMA
127mput TCR 4 or TCRID 3145728
128chk 207 and eq rtlinit DMA 0 and eq get rs S_ICUNK 1 eq get rs S_MCFG 2
129mchip DMA
130put mc M_RSTK 1
131chk 208 eq rtlinit DMA E_RSTTMO
132chk 209 eq get rs S_READY 0
133mchip DMA
134put mc M_FIFO 1
135mput MCUCMD 1 0
136mput INTRMIT 2 0
137mput LLFIFO 2 0
138chk 210 and eq rtlinit DMA 0 eq get rs S_WTO 6
139mchip DMA
140chk 211 eq rtlinit add DMA 256 E_MEM
141chk 212 eq rtlinit 18446744073709547520 E_MEM
142chk 213 eq get mc M_WRS 0
143end
144
145fn tmac to void
146mchip DMA
147mput BAKADR0 4 0
148mput BAKADR1 2 0
149chk 301 and eq rtlinit DMA 0 eq get rs S_MACSRC MS_MAC0
150chk 302 eq get rs add S_MAC0 0 160
151mchip DMA
152mput BAKADR0 4 255
153for i ulong 6
154put mreg add MAC0 i 255
155end
156chk 303 and eq rtlinit DMA 0 eq get rs S_MACSRC MS_FALL
157chk 304 and ne and get rs add S_MAC0 0 2 0 eq and get rs add S_MAC0 0 1 0
158end
159
160fn ttx to void
161chk 401 eq up 0
162fill 100 7
163chk 402 eq rtltx 100 0
164chk 403 and eq get mc M_TXC 1 eq get mtxl 0 100
165chk 404 eq get mtxf 0 217
166chk 405 eq mget SWTAIL0 4 add get rs S_CLOB 1
167chk 406 eq rtltxpend 1
168chk 407 and eq rtltxrec 0 eq get rs S_RECL 1
169chk 408 eq rtltxpend 0
170fill 20 3
171chk 409 eq rtltx 20 0
172chk 410 eq get mtxl 1 60
173chk 411 eq get mtxf 104 0
174chk 412 eq get mtxf 83 226
175chk 413 eq rtltx 13 E_ARG
176chk 414 eq rtltx 1515 E_ARG
177chk 415 eq rtltx 1514 0
178chk 416 eq get mtxl 2 1514
179w = rtltxrec
180chk 417 eq get mc M_DMAF 0
181mchip DMA
182w = rtlinit DMA
183put mc M_DEFR 1
184ok = ulong 0
185for i ulong TXN
186fill 64 i
187if eq rtltx 64 0
188ok = add ok 1
189end
190end
191chk 418 eq ok 16
192chk 419 eq rtltx 64 E_FULL
193chk 420 and eq rtltxrec 0 eq get rs S_RECL 0
194put mc M_CLO add get mc M_CLO 16
195mput HWCLO0 4 get mc M_CLO
196chk 421 and eq rtltxrec 0 eq get rs S_RECL 16
197chk 422 eq rtltx 64 0
198chk 423 eq get mc M_DMAF 0
199put mc M_DEFR 0
200mchip DMA
201w = rtlinit DMA
202bad = ulong 0
203for i ulong 40
204fill 60 i
205if ne rtltx 60 0
206bad = add bad 1
207end
208w = rtltxrec
209if lt i 64
210if ne ulong get mtxf mul i 64 ulong and mul i 31 255
211bad = add bad 1
212end
213end
214end
215chk 424 eq bad 0
216chk 425 eq get mc M_DMAF 0
217chk 426 eq rtltxpend 0
218mchip DMA
219w = rtlinit DMA
220put mc M_HCLO 1
221fill 60 1
222w = rtltx 60
223chk 427 eq rtltxrec E_DEVICE
224chk 428 eq rtltx 60 E_BROKEN
225chk 429 eq rtlrx E_BROKEN
226end
227
228fn trx to void
229chk 501 eq up 0
230for i ulong 60
231put mrxf i uchar add 100 i
232end
233chk 502 eq mrxin 60 0 0 0
234chk 503 and eq rtlrx 0 eq get rs S_RXLEN 60
235ok = ulong 0
236for i ulong 60
237if eq get obuf i uchar add 100 i
238ok = add ok 1
239end
240end
241chk 504 eq ok 60
242chk 505 and eq rtlrx 0 eq get rs S_RXLEN 0
243bad = ulong 0
244for k ulong 40
245for i ulong 80
246put mrxf i uchar and add k i 255
247end
248if ne mrxin 80 0 0 0
249bad = add bad 1
250end
251w = rtlrx
252if ne get rs S_RXLEN 80
253bad = add bad 1
254end
255if ne get obuf 0 uchar and k 255
256bad = add bad 1
257end
258end
259chk 506 eq bad 0
260chk 507 eq get mc M_DMAF 0
261w = mrxin 10 0 0
262chk 508 and eq rtlrx 0 and eq get rs S_RXLEN 0 eq get rs S_RXDRP 1
263w = mrxin 60 RXRES 0
264chk 509 and eq rtlrx 0 and eq get rs S_RXLEN 0 eq get rs S_RXDRP 2
265chk 510 eq mrxin 60 0 0 0
266chk 511 and eq rtlrx 0 eq get rs S_RXLEN 60
267bad = ulong 0
268for k ulong RXN
269if ne mrxin 60 0 0 0
270bad = add bad 1
271end
272end
273chk 512 eq bad 0
274chk 513 and eq mrxin 60 0 0 2 eq get mc M_RXOV 1
275for k ulong RXN
276w = rtlrx
277end
278chk 514 and eq get rs S_BROKE 0 eq get mc M_DMAF 0
279chk 515 eq mrxin 60 0 5000 0
280chk 516 eq rtlrx E_DEVICE
281chk 517 eq rtlrx E_BROKEN
282end
283
284fn tlink to void
285chk 601 eq up 0
286mput PHYSTAT 2 16386
287chk 602 and eq rtllink 1 eq get rs S_MBPS 10000
288mput PHYSTAT 2 4098
289chk 603 and eq rtllink 1 eq get rs S_MBPS 5000
290mput PHYSTAT 2 1026
291chk 604 and eq rtllink 1 eq get rs S_MBPS 2500
292mput PHYSTAT 2 18
293chk 605 and eq rtllink 1 eq get rs S_MBPS 1000
294mput PHYSTAT 2 10
295chk 606 and eq rtllink 1 eq get rs S_MBPS 100
296mput PHYSTAT 2 6
297chk 607 and eq rtllink 1 eq get rs S_MBPS 10
298mput PHYSTAT 2 2
299chk 608 and eq rtllink 1 eq get rs S_MBPS 0
300mput PHYSTAT 2 16384
301chk 609 and eq rtllink 0 eq get rs S_MBPS 0
302mput PHYSTAT 2 65535
303chk 610 eq rtllink 0
304end
305
306fn tstop to void
307chk 701 eq up 0
308chk 702 eq rtlstop 0
309chk 703 and eq get rs S_READY 0 eq get mc M_RSTS 3
310chk 704 and eq mget IMR0 4 0 eq mget ISR0 4 0
311fill 60 1
312chk 705 eq rtltx 60 E_NOTRDY
313chk 706 eq rtlrx E_NOTRDY
314end
315
316fn main to int
317tinit
318tinit2
319trefuse
320tmac
321ttx
322trx
323tlink
324tstop
325w = long 0
326if eq get tt 1 0
327w = write 1 tpass 0 len tpass
328else
329w = write 1 tfail 0 len tfail
330end
331pnum get tt 0
332w = write 1 tfl2 0 len tfl2
333pnum get tt 1
334w = write 1 tnl 0 1
335if ne get tt 1 0
336exit int 1
337end
338ret 0
339end