Print more informations on bus error.
[linux-2.6/linux-mips.git] / arch / cris / lib / old_checksum.c
blob5d4d9bc4b05709798544af96d86834d860534760
1 /* $Id: old_checksum.c,v 1.1.1.1 2001/12/17 13:59:27 bjornw 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
13 * for more names.
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>
23 #undef PROFILE_CHECKSUM
25 #ifdef PROFILE_CHECKSUM
26 /* these are just for profiling the checksum code with an oscillioscope.. uh */
27 #if 0
28 #define BITOFF *((unsigned char *)0xb0000030) = 0xff
29 #define BITON *((unsigned char *)0xb0000030) = 0x0
30 #endif
31 #include <asm/io.h>
32 #define CBITON LED_ACTIVE_SET(1)
33 #define CBITOFF LED_ACTIVE_SET(0)
34 #define BITOFF
35 #define BITON
36 #else
37 #define BITOFF
38 #define BITON
39 #define CBITOFF
40 #define CBITON
41 #endif
44 * computes a partial checksum, e.g. for TCP/UDP fragments
47 #include <asm/delay.h>
49 unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
52 * Experiments with ethernet and slip connections show that buff
53 * is aligned on either a 2-byte or 4-byte boundary.
55 const unsigned char *endMarker = buff + len;
56 const unsigned char *marker = endMarker - (len % 16);
57 #if 0
58 if((int)buff & 0x3)
59 printk("unaligned buff %p\n", buff);
60 __delay(900); /* extra delay of 90 us to test performance hit */
61 #endif
62 BITON;
63 while (buff < marker) {
64 sum += *((unsigned short *)buff)++;
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)++;
73 marker = endMarker - (len % 2);
74 while(buff < marker) {
75 sum += *((unsigned short *)buff)++;
77 if(endMarker - buff > 0) {
78 sum += *buff; /* add extra byte separately */
80 BITOFF;
81 return(sum);