Skip to content

Commit 4557f5d

Browse files
bictorvlarsbrinkhoff
authored andcommitted
Check checksum on CH11 under KLH10
1 parent b7fc027 commit 4557f5d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/system/chaos.291 src/system/chaos.292

+33
Original file line numberDiff line numberDiff line change
@@ -2426,29 +2426,47 @@ BBLK
24262426
JRST [ AOS CHNLOS ;No buffers, lose this packet
24272427
JRST CHXBK1 ]
24282428
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
24292439
CHSRC1: IORDI B,CAIRBF
2440+
IFN KLH10P,ADD J,B
24302441
IORDI C,CAIRBF
2442+
IFN KLH10P,ADD J,C
24312443
PACK16 B,(A)
24322444
AOBJN A,CHSRC1
24332445
PUSHJ P,CHSHDR ;Decode the header
24342446
JRST CHSRC4 ;No byte swapping
24352447
JUMPGE D,CHSRC3
24362448
CHSRC2: IORDI B,CAIRBF ;Read out the data, byte-swapped
2449+
IFN KLH10P,ADD J,B
24372450
IORDI C,CAIRBF
2451+
IFN KLH10P,ADD J,C
24382452
PACK8 B,(D)
24392453
AOBJN D,CHSRC2
24402454
CHSRC3: JUMPGE H,CHSRC7 ;Jump if even packet length
24412455
IORDI B,CAIRBF ;Residual halfword
2456+
IFN KLH10P,ADD J,B
24422457
SETZ C, ;Somebody depends on zero here
24432458
PACK8 B,(D)
24442459
AOJA D,CHSRC7
24452460

24462461
CHSRC4: JUMPGE D,CHSRC6
24472462
CHSRC5: IORDI B,CAIRBF ;Read out the data, halfwords
2463+
IFN KLH10P,ADD J,B
24482464
IORDI C,CAIRBF
2465+
IFN KLH10P,ADD J,C
24492466
PACK16 B,(D)
24502467
AOBJN D,CHSRC5
24512468
CHSRC6: JUMPL H,[ IORDI B,CAIRBF ;Residual halfword
2469+
IFN KLH10P, ADD J,B
24522470
SETZ C, ;Somebody depends on zero here
24532471
PACK16 B,(D)
24542472
AOJA D,CHSRC7 ]
@@ -2457,8 +2475,23 @@ CHSRC7: SUB D,R ;AOBJN pointer minus number of words in packet
24572475
JRST [ AOS CHNPLE ;Packet length disagrees with hardware length
24582476
JRST CHXBK2 ]
24592477
IORDI T,CAIRBF ;Read the three hardware header words
2478+
IFN KLH10P,ADD J,T
24602479
IORDI T,CAIRBF
2480+
IFN KLH10P,ADD J,T
24612481
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::]
24622495
IORDI T,CAICSR
24632496
TRNE T,%CAERR ;Make sure packet came out of RAM okay
24642497
JRST [ AOS CHNCR2 ;Garbage, try again

0 commit comments

Comments
 (0)