I'm sorry for all the fuzz. I'm really nagging the list.
I'm wondering what is the best way to calculate the IP checksum on the
microengines? As I'm aware, there are ways to optimize this calculation
for routers, as they usually only lower the ttl field, but I'm altering
the ip addresses. So I guess I'll have to recalculate the whole thing?
This function does this on the StrongARM:
ix_16bit_t CalcChecksum(ix_8bit_t *addr, ix_16bit_t size) {
ix_32bit_t sum = 0;
while ( size > 1 ) {
sum += *(unsigned short *)(void *)addr;
addr += 2;
size -= 2;
}
if ( size > 0 ) {
sum += *(unsigned char *)addr;
}
while ( sum >> 16 ) {
sum = ( sum & 0xffff ) + ( sum >> 16 );
}
return (~sum);
};
Now, how do I translate this function to microcode? Should I write my
values to memory, reread the header and calculate the checksum and then
write the checksum? Or should I calculate the checksum from GPRs holding
the values I want to write?
Sorry for another, prossibly stupid, question. I'm in a bit of a hurry u
see.
--
Øyvind Hvamstad