[NET]: Cris checksum annotations and cleanups.

* sanitize prototypes and annotate
* kill cast-as-lvalue abuses in csum_partial()
* usual ntohs-equals-shift for checksum purposes

Signed-off-by: Al Viro <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
Al Viro 2006-11-14 21:15:19 -08:00 • committed by David S. Miller
commit 3532010bcf
4 changed files with 57 additions and 59 deletions

View file

@ -47,39 +47,41 @@
#include <asm/delay.h>
unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
__wsum csum_partial(const void *p, int len, __wsum __sum)
{
/*
* Experiments with ethernet and slip connections show that buff
* is aligned on either a 2-byte or 4-byte boundary.
*/
const unsigned char *endMarker = buff + len;
const unsigned char *marker = endMarker - (len % 16);
u32 sum = (__force u32)__sum;
const u16 *buff = p;
/*
* Experiments with ethernet and slip connections show that buff
* is aligned on either a 2-byte or 4-byte boundary.
*/
const void *endMarker = p + len;
const void *marker = endMarker - (len % 16);
#if 0
if((int)buff & 0x3)
printk("unaligned buff %p\n", buff);
__delay(900); /* extra delay of 90 us to test performance hit */
if((int)buff & 0x3)
printk("unaligned buff %p\n", buff);
__delay(900); /* extra delay of 90 us to test performance hit */
#endif
BITON;
while (buff < marker) {
sum += *((unsigned short *)buff)++;
sum += *((unsigned short *)buff)++;
sum += *((unsigned short *)buff)++;
sum += *((unsigned short *)buff)++;
sum += *((unsigned short *)buff)++;
sum += *((unsigned short *)buff)++;
sum += *((unsigned short *)buff)++;
sum += *((unsigned short *)buff)++;
}
marker = endMarker - (len % 2);
while(buff < marker) {
sum += *((unsigned short *)buff)++;
}
if(endMarker - buff > 0) {
sum += *buff; /* add extra byte seperately */
}
BITOFF;
return(sum);
BITON;
while (buff < marker) {
sum += *buff++;
sum += *buff++;
sum += *buff++;
sum += *buff++;
sum += *buff++;
sum += *buff++;
sum += *buff++;
sum += *buff++;
}
marker = endMarker - (len % 2);
while (buff < marker)
sum += *buff++;
if (endMarker > buff)
sum += *(const u8 *)buff; /* add extra byte seperately */
BITOFF;
return (__force __wsum)sum;
}
EXPORT_SYMBOL(csum_partial);