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