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