debuggers.hg

view xen/include/xeno/crc32.h @ 618:4480b471191c

bitkeeper revision 1.259.2.7 (3f0c428fGYxQAV_56B2hOOjYs1PF0A)

Port a bunch of network drivers for low-quality NICS (which will incur extra copying overheads within Xen). But will allow us to work on a wider range of systems at least.
author kaf24@scramble.cl.cam.ac.uk
date Wed Jul 09 16:27:59 2003 +0000 (2003-07-09)
parents
children 125f43340354
line source
1 /*
2 * crc32.h for early Linux 2.4.19pre kernel inclusion
3 * This defines ether_crc_le() and ether_crc() as inline functions
4 * This is slated to change to using the library crc32 functions
5 * as kernel 2.5.2 included at some future date.
6 */
7 #ifndef _LINUX_CRC32_H
8 #define _LINUX_CRC32_H
10 #include <linux/types.h>
12 /* The little-endian AUTODIN II ethernet CRC calculation.
13 N.B. Do not use for bulk data, use a table-based routine instead.
14 This is common code and should be moved to net/core/crc.c */
15 static unsigned const ethernet_polynomial_le = 0xedb88320U;
16 static inline unsigned ether_crc_le(int length, unsigned char *data)
17 {
18 unsigned int crc = 0xffffffff; /* Initial value. */
19 while(--length >= 0) {
20 unsigned char current_octet = *data++;
21 int bit;
22 for (bit = 8; --bit >= 0; current_octet >>= 1) {
23 if ((crc ^ current_octet) & 1) {
24 crc >>= 1;
25 crc ^= ethernet_polynomial_le;
26 } else
27 crc >>= 1;
28 }
29 }
30 return crc;
31 }
33 static unsigned const ethernet_polynomial = 0x04c11db7U;
34 static inline u32 ether_crc(int length, unsigned char *data)
35 {
36 int crc = -1;
37 while (--length >= 0) {
38 unsigned char current_octet = *data++;
39 int bit;
40 for (bit = 0; bit < 8; bit++, current_octet >>= 1) {
41 crc = (crc << 1) ^
42 ((crc < 0) ^ (current_octet & 1) ?
43 ethernet_polynomial : 0);
44 }
45 }
46 return crc;
47 }
49 #endif /* _LINUX_CRC32_H */