[ixp1200] Ip checksum?

Hussain, Sajjad Sajjad.Hussain at adc.com
Mon Jun 21 11:25:10 EDT 2004


Hi Øyvind Hvamstad,

There is a file called cksum32.uc that comes with the IXP Workbench(Microcode\examples\cksum32.uc). It contains code for verifying IP checksum but you can easily modify it according to your need. I am pasting the code in case you don't have access to the example file.




; Prerequisite Register Usage:
;	symbol
;	iphdr1	- 1st longword of IP header
;	iphdr2	- 2nd longword of IP header
;	iphdr3	- 3rd longword of IP header
;	iphdr4	- 4th longword of IP header (IP Source Address)
;	iphdr5	- 5th longword of IP header (IP Dest Address)
;
; Description:
;   The iphdr is assumed to be longword aligned in advance
;   If the checksum is bad, a branch to bad_header_checksum# occurs
;
	alu[accum, iphdr1, +, iphdr2]	 	; Add 1st and 2nd IP longword
	alu[accum, accum, +carry, iphdr3] 	; Add 3rd IP longword
	alu[accum, accum, +carry, iphdr4] 	; Add 4th IP longword	
	alu[accum, accum, +carry, iphdr5] 	; Add 5th IP longword
	alu[accum, accum, +carry, 0]		; Add any carry
	ld_field_w_clr[temp, 1100, accum]		; Get high 16 of the total
	alu_shf[accum, temp, +, accum, <<16]	; Add low 16 bits
	alu[temp, 1, +carry, temp, <<16]		; add last carry +1, temp B op=0
	alu[accum, accum, +, temp, <<16]		; add (1+carry)<<16 to 0xffff to get zero result
	br!=0[bad_header_checksum#]		
	br[end#]
;
bad_header_checksum#:
	immed[bad_header, 0xFFFF]
	nop
; transactor - consume cycles
end#:
	ctx_arb[voluntary]
	br[end#]



More information about the ixp1200 mailing list