@@ -2426,29 +2426,47 @@ BBLK
2426
2426
JRST [ AOS CHNLOS ;No buffers, lose this packet
2427
2427
JRST CHXBK1 ]
2428
2428
HRLI A,-%CPKDT ;Copy out the packet header
2429
+ ;; The KLH10P-marked code is a workaround for a bug in the
2430
+ ;; KLH10 implementation of the CH11. It seems to be a synchronization
2431
+ ;; bug which results in packets being corrupted after being received
2432
+ ;; from the net, and before being read by the 10.
2433
+ ;; The workaround is to compute the checksum here, and verify it.
2434
+ ;; When someone either fixes the CH11 bug or simply reimplements it,
2435
+ ;; this code should be taken out again.
2436
+ ;; Note that the performance impact is very small.
2437
+ ;; /BV November 2024.
2438
+ IFN KLH10P,SETZ J, ; Clear checksum
2429
2439
CHSRC1: IORDI B,CAIRBF
2440
+ IFN KLH10P,ADD J,B
2430
2441
IORDI C,CAIRBF
2442
+ IFN KLH10P,ADD J,C
2431
2443
PACK16 B,(A)
2432
2444
AOBJN A,CHSRC1
2433
2445
PUSHJ P,CHSHDR ;Decode the header
2434
2446
JRST CHSRC4 ;No byte swapping
2435
2447
JUMPGE D,CHSRC3
2436
2448
CHSRC2: IORDI B,CAIRBF ;Read out the data, byte-swapped
2449
+ IFN KLH10P,ADD J,B
2437
2450
IORDI C,CAIRBF
2451
+ IFN KLH10P,ADD J,C
2438
2452
PACK8 B,(D)
2439
2453
AOBJN D,CHSRC2
2440
2454
CHSRC3: JUMPGE H,CHSRC7 ;Jump if even packet length
2441
2455
IORDI B,CAIRBF ;Residual halfword
2456
+ IFN KLH10P,ADD J,B
2442
2457
SETZ C, ;Somebody depends on zero here
2443
2458
PACK8 B,(D)
2444
2459
AOJA D,CHSRC7
2445
2460
2446
2461
CHSRC4: JUMPGE D,CHSRC6
2447
2462
CHSRC5: IORDI B,CAIRBF ;Read out the data, halfwords
2463
+ IFN KLH10P,ADD J,B
2448
2464
IORDI C,CAIRBF
2465
+ IFN KLH10P,ADD J,C
2449
2466
PACK16 B,(D)
2450
2467
AOBJN D,CHSRC5
2451
2468
CHSRC6: JUMPL H,[ IORDI B,CAIRBF ;Residual halfword
2469
+ IFN KLH10P, ADD J,B
2452
2470
SETZ C, ;Somebody depends on zero here
2453
2471
PACK16 B,(D)
2454
2472
AOJA D,CHSRC7 ]
@@ -2457,8 +2475,23 @@ CHSRC7: SUB D,R ;AOBJN pointer minus number of words in packet
2457
2475
JRST [ AOS CHNPLE ;Packet length disagrees with hardware length
2458
2476
JRST CHXBK2 ]
2459
2477
IORDI T,CAIRBF ;Read the three hardware header words
2478
+ IFN KLH10P,ADD J,T
2460
2479
IORDI T,CAIRBF
2480
+ IFN KLH10P,ADD J,T
2461
2481
IORDI T,CAIRBF
2482
+ IFN KLH10P,ADD J,T
2483
+ IFN KLH10P,[ ; Wrap it up - see IPCKS3
2484
+ CHSRCZ::CAILE J,177777 ; Does the checksum fit?
2485
+ JRST [ LDB Q,[202400,,J] ; No, get overflow bits
2486
+ ANDI J,177777 ; then clear them
2487
+ ADDI J,(Q) ; and add at low end
2488
+ JRST CHSRCZ ]
2489
+ ANDCAI J,177777 ; Make ones complement
2490
+ JUMPE J,CHSRCY ; No problem
2491
+ AOS CHNCR2 ; CRC checksum error after reading
2492
+ ;; BUG CHECK,[Chaos: CRC error - cks =],OCT,J
2493
+ JRST CHXBK2
2494
+ CHSRCY::]
2462
2495
IORDI T,CAICSR
2463
2496
TRNE T,%CAERR ;Make sure packet came out of RAM okay
2464
2497
JRST [ AOS CHNCR2 ;Garbage, try again
0 commit comments