diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/cris/arch-v10/lib/old_checksum.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/cris/arch-v10/lib/old_checksum.c')
-rw-r--r-- | arch/cris/arch-v10/lib/old_checksum.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/arch/cris/arch-v10/lib/old_checksum.c b/arch/cris/arch-v10/lib/old_checksum.c new file mode 100644 index 000000000000..22a6f0aa9cef --- /dev/null +++ b/arch/cris/arch-v10/lib/old_checksum.c | |||
@@ -0,0 +1,85 @@ | |||
1 | /* $Id: old_checksum.c,v 1.3 2003/10/27 08:04:32 starvik Exp $ | ||
2 | * | ||
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. | ||
6 | * | ||
7 | * IP/TCP/UDP checksumming routines | ||
8 | * | ||
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 | ||
13 | * for more names. | ||
14 | * | ||
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. | ||
19 | */ | ||
20 | |||
21 | #include <net/checksum.h> | ||
22 | #include <net/module.h> | ||
23 | |||
24 | #undef PROFILE_CHECKSUM | ||
25 | |||
26 | #ifdef PROFILE_CHECKSUM | ||
27 | /* these are just for profiling the checksum code with an oscillioscope.. uh */ | ||
28 | #if 0 | ||
29 | #define BITOFF *((unsigned char *)0xb0000030) = 0xff | ||
30 | #define BITON *((unsigned char *)0xb0000030) = 0x0 | ||
31 | #endif | ||
32 | #include <asm/io.h> | ||
33 | #define CBITON LED_ACTIVE_SET(1) | ||
34 | #define CBITOFF LED_ACTIVE_SET(0) | ||
35 | #define BITOFF | ||
36 | #define BITON | ||
37 | #else | ||
38 | #define BITOFF | ||
39 | #define BITON | ||
40 | #define CBITOFF | ||
41 | #define CBITON | ||
42 | #endif | ||
43 | |||
44 | /* | ||
45 | * computes a partial checksum, e.g. for TCP/UDP fragments | ||
46 | */ | ||
47 | |||
48 | #include <asm/delay.h> | ||
49 | |||
50 | unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum) | ||
51 | { | ||
52 | /* | ||
53 | * Experiments with ethernet and slip connections show that buff | ||
54 | * is aligned on either a 2-byte or 4-byte boundary. | ||
55 | */ | ||
56 | const unsigned char *endMarker = buff + len; | ||
57 | const unsigned char *marker = endMarker - (len % 16); | ||
58 | #if 0 | ||
59 | if((int)buff & 0x3) | ||
60 | printk("unaligned buff %p\n", buff); | ||
61 | __delay(900); /* extra delay of 90 us to test performance hit */ | ||
62 | #endif | ||
63 | BITON; | ||
64 | while (buff < marker) { | ||
65 | sum += *((unsigned short *)buff)++; | ||
66 | sum += *((unsigned short *)buff)++; | ||
67 | sum += *((unsigned short *)buff)++; | ||
68 | sum += *((unsigned short *)buff)++; | ||
69 | sum += *((unsigned short *)buff)++; | ||
70 | sum += *((unsigned short *)buff)++; | ||
71 | sum += *((unsigned short *)buff)++; | ||
72 | sum += *((unsigned short *)buff)++; | ||
73 | } | ||
74 | marker = endMarker - (len % 2); | ||
75 | while(buff < marker) { | ||
76 | sum += *((unsigned short *)buff)++; | ||
77 | } | ||
78 | if(endMarker - buff > 0) { | ||
79 | sum += *buff; /* add extra byte seperately */ | ||
80 | } | ||
81 | BITOFF; | ||
82 | return(sum); | ||
83 | } | ||
84 | |||
85 | EXPORT_SYMBOL(csum_partial); | ||