1 /* $Id: old_checksum.c,v 1.3 2003/10/27 08:04:32 starvik Exp $
3 * INET An implementation of the TCP/IP protocol suite for the LINUX
4 * operating system. INET is implemented using the BSD Socket
5 * interface as the means of communication with the user level.
7 * IP/TCP/UDP checksumming routines
9 * Authors: Jorge Cwik, <jorge@laser.satlink.net>
10 * Arnt Gulbrandsen, <agulbra@nvg.unit.no>
11 * Tom May, <ftom@netcom.com>
12 * Lots of code moved from tcp.c and ip.c; see those files
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version
18 * 2 of the License, or (at your option) any later version.
21 #include <net/checksum.h>
22 #include <net/module.h>
24 #undef PROFILE_CHECKSUM
26 #ifdef PROFILE_CHECKSUM
27 /* these are just for profiling the checksum code with an oscillioscope.. uh */
29 #define BITOFF *((unsigned char *)0xb0000030) = 0xff
30 #define BITON *((unsigned char *)0xb0000030) = 0x0
33 #define CBITON LED_ACTIVE_SET(1)
34 #define CBITOFF LED_ACTIVE_SET(0)
45 * computes a partial checksum, e.g. for TCP/UDP fragments
48 #include <asm/delay.h>
50 __wsum csum_partial(const void *p, int len, __wsum __sum)
52 u32 sum = (__force u32)__sum;
55 * Experiments with ethernet and slip connections show that buff
56 * is aligned on either a 2-byte or 4-byte boundary.
58 const void *endMarker = p + len;
59 const void *marker = endMarker - (len % 16);
62 printk("unaligned buff %p\n", buff);
63 __delay(900); /* extra delay of 90 us to test performance hit */
66 while (buff < marker) {
76 marker = endMarker - (len % 2);
81 sum += *(const u8 *)buff; /* add extra byte seperately */
84 return (__force __wsum)sum;
87 EXPORT_SYMBOL(csum_partial);