Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/aienux/net/wire/test_loopback.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / aienux / net / wire / test_loopback.om` 932 lines ยท 16755 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note aienux/net/wire/test_loopback.om: Host loopback integration test for wire_loop.om + omtk.om + tcp.om. 3 note Compose: 4 note { printf 'om2\n'; cat aienux/net/tcp/tcp.om aienux/net/wire/omtk.om aienux/net/wire/wire_loop.om aienux/net/wire/test_loopback.om; } | seed/out/omc > /tmp/test_loopback 5 note Strictly host-only (NOT_RUN on Spark silicon). 6 7 note Simulated hardware & peer state 8 note sim_g: 0 cntvct, 1 cntfrq, 2 dsb_cnt, 3 kicks, 4 quar_cnt, 5 sem_ready, 9 note 6 irq_rc (signed in sim_irq), 7 ver_rc (signed in sim_ver), 8 next_tok, 10 note 9 stop_flag, 10 reset_kicks, 11 stage_cnt, 12 last_reset_keep, 13 reclaim_cnt, 11 note 14 out_tok (poisoned to 0xFFFFFFFF on mode=0 MODE_PREFILL per Piece 5 #20) 12 global sim_g ulong 16 13 global sim_irq long 1 14 global sim_ver long 1 15 16 note Simulated NIC RX queue (Peer -> Spark): 4 slots of 2048 B 17 global srx_buf uchar 8192 18 global srx_len ulong 4 19 global srx_hd ulong 1 20 global srx_cnt ulong 1 21 22 note Captured TCP payload bytes sent by Spark -> Peer (reassembled from Ttx frames) 23 global cap_buf uchar 65536 24 global cap_len ulong 1 25 global cap_pos ulong 1 26 27 note Peer TCP sequence tracking: 0 peer_seq, 1 peer_ack, 2 peer_port, 3 spark_isn, 4 fin_seen 28 global peer_st ulong 8 29 global pkt_tmp uchar 2048 30 global app_tmp uchar 16400 31 32 text Tpass "WIRE_LOOP_LOOPBACK PASS cases=18\n" 33 text Tfail "WIRE_LOOP_LOOPBACK FAIL case=" 34 text Tnl "\n" 35 global tnum uchar 32 36 37 fn tput_num v ulong to void 38 i = ulong 32 39 while true bound 21 40 i = sub i 1 41 put tnum i uchar add 48 rem v 10 42 v = div v 10 43 if eq v 0 44 break 45 end 46 end 47 k = write 1 tnum i sub 32 i 48 end 49 50 fn tfail c ulong to void 51 k = write 1 Tfail 0 len Tfail 52 tput_num c 53 k = write 1 Tnl 0 len Tnl 54 exit int c 55 end 56 57 note ---- Seam implementations required by wire_loop.om ---- 58 fn wl_cntvct to ulong 59 ret get sim_g 0 60 end 61 62 fn wl_cntfrq to ulong 63 ret get sim_g 1 64 end 65 66 fn wl_dsb_ish to void 67 put sim_g 2 add get sim_g 2 1 68 end 69 70 fn wl_nic_rx to ulong 71 cnt = get srx_cnt 0 72 if eq cnt 0 73 ret 0 74 end 75 hd = get srx_hd 0 76 n = get srx_len hd 77 base = mul hd 2048 78 i = ulong 0 79 while lt i n bound 2048 80 put Trx i get srx_buf add base i 81 i = add i 1 82 end 83 put srx_hd 0 rem add hd 1 4 84 put srx_cnt 0 sub cnt 1 85 ret n 86 end 87 88 note Helper: read big-endian u16/u32 from Ttx 89 fn tx_r16 off ulong to ulong 90 a = ulong get Ttx off 91 b = ulong get Ttx add off 1 92 ret or shl a 8 b 93 end 94 95 fn tx_r32 off ulong to ulong 96 a = tx_r16 off 97 b = tx_r16 add off 2 98 ret or shl a 16 b 99 end 100 101 fn tx_cap doff2 ulong dlen ulong to void 102 cl = get cap_len 0 103 i = ulong 0 104 while lt i dlen bound 2048 105 if lt add cl i 65536 106 put cap_buf add cl i get Ttx add doff2 i 107 end 108 i = add i 1 109 end 110 put cap_len 0 add cl dlen 111 end 112 113 note Capture Spark -> Peer frames from Ttx: track SYN-ACK ISN, TCP payload bytes, and FIN. 114 fn wl_nic_tx n ulong to long 115 if lt n 54 116 ret 0 117 end 118 if ne tx_r16 12 2048 119 ret 0 120 end 121 if ne ulong get Ttx 23 6 122 ret 0 123 end 124 tot = tx_r16 16 125 ihl = mul and ulong get Ttx 14 15 4 126 toff = add 14 ihl 127 doff = mul shr ulong get Ttx add toff 12 4 4 128 fl = ulong get Ttx add toff 13 129 seq = tx_r32 add toff 4 130 if ne and fl 2 0 131 put peer_st 3 seq 132 put peer_st 1 and add seq 1 `4294967295` 133 end 134 if ne and fl 1 0 135 put peer_st 4 1 136 end 137 if gt tot add ihl doff 138 dlen = sub tot add ihl doff 139 tx_cap add toff doff dlen 140 put peer_st 1 and add seq dlen `4294967295` 141 end 142 ret 0 143 end 144 145 fn wl_nic_reclaim to void 146 put sim_g 13 add get sim_g 13 1 147 end 148 149 fn wl_q38_reset_kv keep_pos ulong to long 150 put sim_g 12 keep_pos 151 if gt keep_pos 0 152 ret -2 153 end 154 put sim_g 10 add get sim_g 10 1 155 ret 128 156 end 157 158 fn wl_q38_stage_step tok_in uint kv_pos uint mode uchar to long 159 put sim_g 11 add get sim_g 11 1 160 if eq mode 0 161 put sim_g 14 `4294967295` 162 else 163 t = get sim_g 8 164 put sim_g 14 t 165 put sim_g 8 add t 1 166 end 167 ret 256 168 end 169 170 fn wl_q38_verify_step to long 171 ret get sim_ver 0 172 end 173 174 fn wl_q38_read_tok to uint 175 ret uint get sim_g 14 176 end 177 178 fn wl_gpu_kick pb_words uint to long 179 put sim_g 3 add get sim_g 3 1 180 ret 0 181 end 182 183 fn wl_gpu_poll to long 184 if eq get sim_g 5 0 185 ret 0 186 end 187 ret 1 188 end 189 190 fn wl_gpu_irq_check to long 191 ret get sim_irq 0 192 end 193 194 fn wl_gpu_quarantine to void 195 put sim_g 4 add get sim_g 4 1 196 end 197 198 fn wl_should_stop to ulong 199 ret get sim_g 9 200 end 201 202 note ---- Peer Ethernet/IPv4/TCP frame builder ---- 203 fn pw16 off ulong v ulong to void 204 put pkt_tmp off uchar and shr v 8 255 205 put pkt_tmp add off 1 uchar and v 255 206 end 207 208 fn pw32 off ulong v ulong to void 209 pw16 off and shr v 16 65535 210 pw16 add off 2 and v 65535 211 end 212 213 fn psum off ulong n ulong to ulong 214 s = ulong 0 215 while ge n 2 bound 1024 216 a = ulong get pkt_tmp off 217 b = ulong get pkt_tmp add off 1 218 s = add s or shl a 8 b 219 off = add off 2 220 n = sub n 2 221 end 222 if eq n 1 223 s = add s shl ulong get pkt_tmp off 8 224 end 225 ret s 226 end 227 228 fn pfold s ulong to ulong 229 while gt s 65535 bound 8 230 s = add and s 65535 shr s 16 231 end 232 ret xor s 65535 233 end 234 235 note Enqueue pkt_tmp[0..n) into Spark's NIC RX ring. 236 fn penq n ulong to void 237 cnt = get srx_cnt 0 238 if ge cnt 4 239 tfail 90 240 end 241 slot = rem add get srx_hd 0 cnt 4 242 base = mul slot 2048 243 i = ulong 0 244 while lt i n bound 2048 245 put srx_buf add base i get pkt_tmp i 246 i = add i 1 247 end 248 put srx_len slot n 249 put srx_cnt 0 add cnt 1 250 end 251 252 note Send one TCP segment from Peer (10.0.0.1:peer_port) to Spark (10.0.0.2:18100). 253 note Payload bytes come from app_tmp[off..off+dlen). 254 fn psend flags ulong off ulong dlen ulong to void 255 note Dst MAC = Spark MAC (02:00:00:00:00:02), Src MAC = Peer MAC (02:00:00:00:00:01) 256 put pkt_tmp 0 2 257 put pkt_tmp 1 0 258 put pkt_tmp 2 0 259 put pkt_tmp 3 0 260 put pkt_tmp 4 0 261 put pkt_tmp 5 2 262 put pkt_tmp 6 2 263 put pkt_tmp 7 0 264 put pkt_tmp 8 0 265 put pkt_tmp 9 0 266 put pkt_tmp 10 0 267 put pkt_tmp 11 1 268 pw16 12 2048 269 note IPv4 header at 14..34 270 tot = add 40 dlen 271 put pkt_tmp 14 69 272 put pkt_tmp 15 0 273 pw16 16 tot 274 pw16 18 1 275 pw16 20 16384 276 put pkt_tmp 22 64 277 put pkt_tmp 23 6 278 pw16 24 0 279 pw32 26 `167772161` 280 pw32 30 `167772162` 281 pw16 24 pfold psum 14 20 282 note TCP header at 34..54 283 pw16 34 get peer_st 2 284 pw16 36 18100 285 seq = get peer_st 0 286 pw32 38 seq 287 pw32 42 get peer_st 1 288 put pkt_tmp 46 80 289 put pkt_tmp 47 uchar and flags 255 290 pw16 48 65535 291 pw16 50 0 292 pw16 52 0 293 i = ulong 0 294 while lt i dlen bound 1500 295 put pkt_tmp add 54 i get app_tmp add off i 296 i = add i 1 297 end 298 tlen = add 20 dlen 299 ps = ulong 5123 300 ps = add ps add 6 tlen 301 ps = add ps psum 34 tlen 302 pw16 50 pfold ps 303 if ne and flags 2 0 304 put peer_st 0 and add seq 1 `4294967295` 305 else 306 put peer_st 0 and add seq dlen `4294967295` 307 end 308 flen = add 54 dlen 309 if lt flen 60 310 j = flen 311 while lt j 60 bound 60 312 put pkt_tmp j 0 313 j = add j 1 314 end 315 flen = 60 316 end 317 penq flen 318 end 319 320 note Send app_tmp[0..n) over TCP in <= 1024 B chunks, ticking wire_loop after each. 321 fn psend_data n ulong to void 322 off = ulong 0 323 while lt off n bound 32 324 ch = sub n off 325 if gt ch 1024 326 ch = 1024 327 end 328 psend 24 off ch 329 wl_tick 330 off = add off ch 331 end 332 end 333 334 note Helper: write LE u16/u32 into app_tmp 335 fn aw16 off ulong v ulong to void 336 put app_tmp off uchar and v 255 337 put app_tmp add off 1 uchar and shr v 8 255 338 end 339 340 fn aw32 off ulong v ulong to void 341 put app_tmp off uchar and v 255 342 put app_tmp add off 1 uchar and shr v 8 255 343 put app_tmp add off 2 uchar and shr v 16 255 344 put app_tmp add off 3 uchar and shr v 24 255 345 end 346 347 fn amkhdr op ulong flg ulong req ulong plen ulong to void 348 aw32 0 OMK_MAGIC 349 put app_tmp 4 uchar OMK_VER 350 put app_tmp 5 uchar op 351 aw16 6 flg 352 aw32 8 req 353 aw32 12 plen 354 end 355 356 note Helper: read LE u32 from cap_buf at cap_pos + off 357 fn cr32 off ulong to ulong 358 p = add get cap_pos 0 off 359 a = ulong get cap_buf p 360 b = ulong get cap_buf add p 1 361 c = ulong get cap_buf add p 2 362 d = ulong get cap_buf add p 3 363 ret or or or a shl b 8 shl c 16 shl d 24 364 end 365 366 fn cr16 off ulong to ulong 367 p = add get cap_pos 0 off 368 a = ulong get cap_buf p 369 b = ulong get cap_buf add p 1 370 ret or a shl b 8 371 end 372 373 note Verify next captured OMTK frame has expected op, req_id, plen; advance cap_pos only via cap_adv. 374 fn cap_avail to ulong 375 ret sub get cap_len 0 get cap_pos 0 376 end 377 378 fn cap_chk op ulong req ulong plen ulong tc ulong to void 379 if lt cap_avail add 16 plen 380 tfail tc 381 end 382 if ne cr32 0 OMK_MAGIC 383 tfail tc 384 end 385 p = get cap_pos 0 386 if ne ulong get cap_buf add p 4 OMK_VER 387 tfail tc 388 end 389 if ne ulong get cap_buf add p 5 op 390 tfail tc 391 end 392 if ne cr32 8 req 393 tfail tc 394 end 395 if ne cr32 12 plen 396 tfail tc 397 end 398 end 399 400 fn cap_adv n ulong to void 401 put cap_pos 0 add get cap_pos 0 n 402 end 403 404 note Reset simulator + TCP + wire_loop and perform 3-way TCP handshake. 405 fn setup_conn port ulong to void 406 put sim_g 0 `1000000000` 407 put sim_g 1 `1000000000` 408 put sim_g 2 0 409 put sim_g 3 0 410 put sim_g 4 0 411 put sim_g 5 1 412 put sim_g 8 50 413 put sim_g 9 0 414 put sim_g 10 0 415 put sim_g 11 0 416 put sim_g 12 0 417 put sim_g 13 0 418 put sim_irq 0 0 419 put sim_ver 0 0 420 put srx_hd 0 0 421 put srx_cnt 0 0 422 put cap_len 0 0 423 put cap_pos 0 0 424 put peer_st 0 1000 425 put peer_st 1 0 426 put peer_st 2 port 427 put peer_st 3 0 428 put peer_st 4 0 429 put Tmac 0 2 430 put Tmac 1 0 431 put Tmac 2 0 432 put Tmac 3 0 433 put Tmac 4 0 434 put Tmac 5 2 435 put Tcf 1 `167772162` 436 put Tcf 2 `167772161` 437 put Tcf 3 `4294967040` 438 put Tcf 5 `1234567` 439 tarpset `167772161` `2199023255553` true 440 wl_init 18100 262144 248320 441 psend 2 0 0 442 wl_tick 443 psend 16 0 0 444 wl_tick 445 if ne get Tcb kST 4 446 tfail 91 447 end 448 end 449 450 note Advance simulated CNTVCT_EL0 by ms milliseconds (at 1 GHz = ms * `1000000`). 451 fn adv_ms ms ulong to void 452 put sim_g 0 add get sim_g 0 mul ms `1000000` 453 end 454 455 fn main to int 456 note Case 1: Overflow-safe CNTVCT_EL0 -> ms conversion (5e18 ticks @ 1 GHz = 5e12 ms) 457 put sim_g 0 `5000000000000000000` 458 put sim_g 1 `1000000000` 459 if ne wl_now_ms `5000000000000` 460 tfail 1 461 end 462 463 note Case 2: TCP handshake + PING -> PONG 464 setup_conn 40001 465 amkhdr OMK_PING 0 0 0 466 psend_data 16 467 wl_tick 468 cap_chk OMK_PONG 0 16 2 469 if ne cr32 16 WL_IDLE 470 tfail 2 471 end 472 if ne cr32 20 0 473 tfail 2 474 end 475 if ne cr32 24 262144 476 tfail 2 477 end 478 cap_adv 32 479 480 note Case 3: PREFILL (3 tokens) -> 3 GPU kicks + 3 dsb ish + DONE(kv=3, PREFILL_OK) 481 amkhdr OMK_PREFILL 0 101 12 482 aw32 16 10 483 aw32 20 20 484 aw32 24 30 485 psend_data 28 486 for s ulong 12 487 wl_tick 488 end 489 cap_chk OMK_DONE 101 8 3 490 if ne cr32 16 3 491 tfail 3 492 end 493 if ne cr32 20 OMK_RPREF 494 tfail 3 495 end 496 if ne get sim_g 3 3 497 tfail 3 498 end 499 if ne get sim_g 2 3 500 tfail 3 501 end 502 cap_adv 24 503 504 note Case 4: DECODE (max=4, eos=52; final prefill produced first token 50 with HASFIRST=1, 505 note then 2 GPU decode steps emit 51 and 52(EOS), final kv=5) 506 if ne get wl_st WL_S_HASFIRST 1 507 tfail 4 508 end 509 amkhdr OMK_DECODE 0 102 16 510 aw32 16 4 511 aw32 20 52 512 aw32 24 0 513 aw32 28 42 514 psend_data 32 515 for s ulong 12 516 wl_tick 517 end 518 cap_chk OMK_TOKEN 102 8 4 519 if ne cr32 16 0 520 tfail 4 521 end 522 if ne cr32 20 50 523 tfail 4 524 end 525 cap_adv 24 526 cap_chk OMK_TOKEN 102 8 4 527 if ne cr32 16 1 528 tfail 4 529 end 530 if ne cr32 20 51 531 tfail 4 532 end 533 cap_adv 24 534 cap_chk OMK_TOKEN 102 8 4 535 if ne cr16 6 OMK_FEOS 536 tfail 4 537 end 538 if ne cr32 16 2 539 tfail 4 540 end 541 if ne cr32 20 52 542 tfail 4 543 end 544 cap_adv 24 545 cap_chk OMK_DONE 102 8 4 546 if ne cr32 16 5 547 tfail 4 548 end 549 if ne cr32 20 OMK_REOS 550 tfail 4 551 end 552 cap_adv 24 553 554 note Case 5: RESET_KV(keep_pos=2) -> ERR(E_UNSUP), kv_pos stays 5, 0 extra kicks 555 k_before = get sim_g 3 556 amkhdr OMK_RESET 0 103 4 557 aw32 16 2 558 psend_data 20 559 wl_tick 560 cap_chk OMK_ERR 103 8 5 561 if ne cr32 16 OMK_EUNSUP 562 tfail 5 563 end 564 if ne get wl_st WL_S_KVPOS 5 565 tfail 5 566 end 567 if ne get sim_g 3 k_before 568 tfail 5 569 end 570 cap_adv 24 571 572 note Case 6: RESET_KV(keep_pos=0) -> MUST wait for GPU semaphore before DONE(kv=0, RESET_OK) 573 put sim_g 5 0 574 amkhdr OMK_RESET 0 0 4 575 aw32 16 0 576 psend_data 20 577 wl_tick 578 wl_tick 579 if ne cap_avail 0 580 tfail 6 581 end 582 if ne get wl_st WL_S_STATE WL_WAIT 583 tfail 6 584 end 585 if ne get sim_g 10 1 586 tfail 6 587 end 588 put sim_g 5 1 589 wl_tick 590 cap_chk OMK_DONE 0 8 6 591 if ne cr32 16 0 592 tfail 6 593 end 594 if ne cr32 20 OMK_RRESET 595 tfail 6 596 end 597 cap_adv 24 598 599 note Case 7: CANCEL mid-DECODE while in WL_WAIT; PING still responds while waiting 600 put wl_st WL_S_KVPOS 1 601 put wl_st WL_S_LASTTOK 50 602 put sim_g 5 0 603 amkhdr OMK_DECODE 0 104 16 604 aw32 16 10 605 aw32 20 999 606 aw32 24 0 607 aw32 28 0 608 psend_data 32 609 wl_tick 610 if ne get wl_st WL_S_STATE WL_WAIT 611 tfail 7 612 end 613 amkhdr OMK_PING 0 105 0 614 psend_data 16 615 wl_tick 616 cap_chk OMK_PONG 105 16 7 617 if ne cr32 16 WL_WAIT 618 tfail 7 619 end 620 cap_adv 32 621 amkhdr OMK_CANCEL 0 104 0 622 psend_data 16 623 wl_tick 624 put sim_g 5 1 625 wl_tick 626 cap_chk OMK_TOKEN 104 8 7 627 cap_adv 24 628 cap_chk OMK_DONE 104 8 7 629 if ne cr32 20 OMK_RCANCEL 630 tfail 7 631 end 632 cap_adv 24 633 634 note Case 8: MAX_CTX overflow-safe refusal + E_BAD_TOK + temp_milli > 0 E_UNSUP 635 put wl_st WL_S_KVPOS 262143 636 k_b8 = get sim_g 3 637 amkhdr OMK_PREFILL 0 106 8 638 aw32 16 1 639 aw32 20 2 640 psend_data 24 641 wl_tick 642 cap_chk OMK_ERR 106 8 8 643 if ne cr32 16 OMK_ERANGE 644 tfail 8 645 end 646 cap_adv 24 647 put wl_st WL_S_KVPOS 0 648 amkhdr OMK_PREFILL 0 107 4 649 aw32 16 248320 650 psend_data 20 651 wl_tick 652 cap_chk OMK_ERR 107 8 8 653 if ne cr32 16 OMK_EBADTOK 654 tfail 8 655 end 656 cap_adv 24 657 amkhdr OMK_DECODE 0 108 16 658 aw32 16 4 659 aw32 20 1 660 aw32 24 700 661 aw32 28 0 662 psend_data 32 663 wl_tick 664 cap_chk OMK_ERR 108 8 8 665 if ne cr32 16 OMK_EUNSUP 666 tfail 8 667 end 668 if ne get sim_g 3 k_b8 669 tfail 8 670 end 671 cap_adv 24 672 673 note Case 9: Malformed frame (bad magic / reserved flag / >16384 payload) -> ERR + close 674 aw32 0 12345 675 put app_tmp 4 1 676 put app_tmp 5 1 677 aw16 6 0 678 aw32 8 109 679 aw32 12 0 680 psend_data 16 681 wl_tick 682 cap_chk OMK_ERR 109 8 9 683 if ne cr32 16 OMK_EBADMAG 684 tfail 9 685 end 686 if eq get peer_st 4 0 687 tfail 9 688 end 689 cap_adv 24 690 691 note Case 10: 30s idle timeout -> tdrop + re-arm tlisten(18100) 692 setup_conn 40002 693 d0 = get wl_st WL_S_DROPS 694 adv_ms 29999 695 wl_tick 696 if ne get wl_st WL_S_DROPS d0 697 tfail 10 698 end 699 adv_ms 2 700 wl_tick 701 if ne get wl_st WL_S_DROPS add d0 1 702 tfail 10 703 end 704 if ne get Tcb kST 1 705 tfail 10 706 end 707 708 note Case 11: Trap #13 guard (q38_verify_step returns -1) -> NO TOKEN, quarantine, ERR(E_GPU_VERIFY), FAULT 709 setup_conn 40003 710 put wl_st WL_S_KVPOS 1 711 put wl_st WL_S_LASTTOK 50 712 put sim_ver 0 -1 713 amkhdr OMK_DECODE 0 110 16 714 aw32 16 2 715 aw32 20 999 716 aw32 24 0 717 aw32 28 0 718 psend_data 32 719 for s ulong 6 720 wl_tick 721 end 722 cap_chk OMK_ERR 110 8 11 723 if ne cr32 16 OMK_EGVER 724 tfail 11 725 end 726 if ne get sim_g 4 1 727 tfail 11 728 end 729 if ne get wl_st WL_S_STATE WL_FAULT 730 tfail 11 731 end 732 cap_adv 24 733 amkhdr OMK_PREFILL 0 111 4 734 aw32 16 5 735 psend_data 20 736 wl_tick 737 cap_chk OMK_ERR 111 8 11 738 if ne cr32 16 OMK_EFAULT 739 tfail 11 740 end 741 cap_adv 24 742 743 note Case 12: GSP HALT (iqservice returns -13) during WL_WAIT -> quarantine + ERR(E_GPU_HALT, 13) + FAULT 744 setup_conn 40004 745 put wl_st WL_S_KVPOS 1 746 put wl_st WL_S_LASTTOK 50 747 put sim_g 5 0 748 amkhdr OMK_DECODE 0 112 16 749 aw32 16 2 750 aw32 20 999 751 aw32 24 0 752 aw32 28 0 753 psend_data 32 754 wl_tick 755 put sim_irq 0 -13 756 wl_tick 757 cap_chk OMK_ERR 112 8 12 758 if ne cr32 16 OMK_EGHALT 759 tfail 12 760 end 761 if ne cr32 20 13 762 tfail 12 763 end 764 if ne get sim_g 4 1 765 tfail 12 766 end 767 if ne get wl_st WL_S_STATE WL_FAULT 768 tfail 12 769 end 770 cap_adv 24 771 772 note Case 13: Truncated TCP frame split across 2 segments + wl_run nested bound entry 773 setup_conn 40005 774 amkhdr OMK_PREFILL 0 113 8 775 aw32 16 7 776 aw32 20 8 777 psend 24 0 10 778 wl_tick 779 if ne cap_avail 0 780 tfail 13 781 end 782 if ne get sim_g 3 0 783 tfail 13 784 end 785 psend 24 10 14 786 for s ulong 8 787 wl_tick 788 end 789 cap_chk OMK_DONE 113 8 13 790 if ne cr32 16 2 791 tfail 13 792 end 793 cap_adv 24 794 put sim_g 9 1 795 wl_run 796 797 note Case 14: Reserved flag bit (flags=4 -> E_BAD_FLAGS) and oversize payload (16388 -> E_TOO_BIG) 798 setup_conn 40006 799 amkhdr OMK_PING 4 114 0 800 psend_data 16 801 wl_tick 802 cap_chk OMK_ERR 114 8 14 803 if ne cr32 16 OMK_EBADFLG 804 tfail 14 805 end 806 cap_adv 24 807 setup_conn 40007 808 aw32 0 OMK_MAGIC 809 put app_tmp 4 uchar OMK_VER 810 put app_tmp 5 uchar OMK_PREFILL 811 aw16 6 0 812 aw32 8 115 813 aw32 12 16388 814 psend_data 16 815 wl_tick 816 cap_chk OMK_ERR 115 8 14 817 if ne cr32 16 OMK_ETOOBIG 818 tfail 14 819 end 820 cap_adv 24 821 822 note Case 15: Disconnect during WL_WAIT -> defer tlisten until GPU drains, zero frame leak to next peer 823 setup_conn 40008 824 put wl_st WL_S_KVPOS 1 825 put wl_st WL_S_LASTTOK 50 826 put sim_g 5 0 827 amkhdr OMK_DECODE 0 116 16 828 aw32 16 4 829 aw32 20 999 830 aw32 24 0 831 aw32 28 0 832 psend_data 32 833 wl_tick 834 if ne get wl_st WL_S_STATE WL_WAIT 835 tfail 15 836 end 837 tdrop 0 838 wl_tick 839 if ne get Tcb kST 0 840 tfail 15 841 end 842 if ne get wl_st WL_S_REARM 1 843 tfail 15 844 end 845 put sim_g 5 1 846 wl_tick 847 wl_tick 848 if ne cap_avail 0 849 tfail 15 850 end 851 if ne get wl_st WL_S_STATE WL_IDLE 852 tfail 15 853 end 854 if ne get wl_st WL_S_REARM 0 855 tfail 15 856 end 857 if ne get Tcb kST 1 858 tfail 15 859 end 860 if ne get wl_st WL_S_CANCEL 0 861 tfail 15 862 end 863 864 note Case 16: wl_txq backpressure -> stay in WL_SUBMIT while < 64 B free, kick once space freed 865 setup_conn 40009 866 k_b16 = get sim_g 3 867 amkhdr OMK_PREFILL 0 117 4 868 aw32 16 7 869 psend 24 0 20 870 n16 = wl_nic_rx 871 tinput n16 872 wl_pump_tcp wl_now_ms 873 if ne get wl_st WL_S_STATE WL_SUBMIT 874 tfail 16 875 end 876 put wl_st WL_S_TXN 4060 877 wl_gpu_submit wl_now_ms 878 if ne get sim_g 3 k_b16 879 tfail 16 880 end 881 if ne get wl_st WL_S_STATE WL_SUBMIT 882 tfail 16 883 end 884 put wl_st WL_S_TXN 0 885 put wl_st WL_S_TXH 0 886 for s ulong 6 887 wl_tick 888 end 889 cap_chk OMK_DONE 117 8 16 890 if ne cr32 16 1 891 tfail 16 892 end 893 cap_adv 24 894 895 note Case 17: RESET_KV(keep > kv_pos) -> ERR(OMK_ERANGE) before calling q38_reset_kv 896 put wl_st WL_S_KVPOS 2 897 put sim_g 12 0 898 amkhdr OMK_RESET 0 118 4 899 aw32 16 5 900 psend_data 20 901 wl_tick 902 cap_chk OMK_ERR 118 8 17 903 if ne cr32 16 OMK_ERANGE 904 tfail 17 905 end 906 if ne get sim_g 12 0 907 tfail 17 908 end 909 cap_adv 24 910 911 note Case 18: Empty-KV DECODE refusal -> ERR(OMK_ERANGE), 0 GPU kicks 912 setup_conn 40010 913 k_b18 = get sim_g 3 914 amkhdr OMK_DECODE 0 119 16 915 aw32 16 4 916 aw32 20 99 917 aw32 24 0 918 aw32 28 0 919 psend_data 32 920 wl_tick 921 cap_chk OMK_ERR 119 8 18 922 if ne cr32 16 OMK_ERANGE 923 tfail 18 924 end 925 if ne get sim_g 3 k_b18 926 tfail 18 927 end 928 cap_adv 24 929 930 k = write 1 Tpass 0 len Tpass 931 ret 0 932 end