aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin
diff options
context:
space:
mode:
Diffstat (limited to 'arch/blackfin')
-rw-r--r--arch/blackfin/Kconfig3
-rw-r--r--arch/blackfin/include/asm/checksum.h70
-rw-r--r--arch/blackfin/lib/Makefile2
-rw-r--r--arch/blackfin/lib/checksum.c125
4 files changed, 8 insertions, 192 deletions
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index ae6a60f10120..c0d444535611 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -28,6 +28,9 @@ config BLACKFIN
28 select HAVE_OPROFILE 28 select HAVE_OPROFILE
29 select ARCH_WANT_OPTIONAL_GPIOLIB 29 select ARCH_WANT_OPTIONAL_GPIOLIB
30 30
31config GENERIC_CSUM
32 def_bool y
33
31config GENERIC_BUG 34config GENERIC_BUG
32 def_bool y 35 def_bool y
33 depends on BUG 36 depends on BUG
diff --git a/arch/blackfin/include/asm/checksum.h b/arch/blackfin/include/asm/checksum.h
index a23415be0de1..623cc7fb00bc 100644
--- a/arch/blackfin/include/asm/checksum.h
+++ b/arch/blackfin/include/asm/checksum.h
@@ -9,63 +9,12 @@
9#define _BFIN_CHECKSUM_H 9#define _BFIN_CHECKSUM_H
10 10
11/* 11/*
12 * computes the checksum of a memory block at buff, length len,
13 * and adds in "sum" (32-bit)
14 *
15 * returns a 32-bit number suitable for feeding into itself
16 * or csum_tcpudp_magic
17 *
18 * this function must be called with even lengths, except
19 * for the last fragment, which may be odd
20 *
21 * it's best to have buff aligned on a 32-bit boundary
22 */
23__wsum csum_partial(const void *buff, int len, __wsum sum);
24
25/*
26 * the same as csum_partial, but copies from src while it
27 * checksums
28 *
29 * here even more important to align src and dst on a 32-bit (or even
30 * better 64-bit) boundary
31 */
32
33__wsum csum_partial_copy(const void *src, void *dst,
34 int len, __wsum sum);
35
36/*
37 * the same as csum_partial_copy, but copies from user space.
38 *
39 * here even more important to align src and dst on a 32-bit (or even
40 * better 64-bit) boundary
41 */
42
43extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
44 int len, __wsum sum, int *csum_err);
45
46#define csum_partial_copy_nocheck(src, dst, len, sum) \
47 csum_partial_copy((src), (dst), (len), (sum))
48
49__sum16 ip_fast_csum(unsigned char *iph, unsigned int ihl);
50
51/*
52 * Fold a partial checksum
53 */
54
55static inline __sum16 csum_fold(__wsum sum)
56{
57 while (sum >> 16)
58 sum = (sum & 0xffff) + (sum >> 16);
59 return ((~(sum << 16)) >> 16);
60}
61
62/*
63 * computes the checksum of the TCP/UDP pseudo-header 12 * computes the checksum of the TCP/UDP pseudo-header
64 * returns a 16-bit checksum, already complemented 13 * returns a 16-bit checksum, already complemented
65 */ 14 */
66 15
67static inline __wsum 16static inline __wsum
68csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, 17__csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
69 unsigned short proto, __wsum sum) 18 unsigned short proto, __wsum sum)
70{ 19{
71 unsigned int carry; 20 unsigned int carry;
@@ -88,19 +37,8 @@ csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
88 37
89 return (sum); 38 return (sum);
90} 39}
40#define csum_tcpudp_nofold __csum_tcpudp_nofold
91 41
92static inline __sum16 42#include <asm-generic/checksum.h>
93csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
94 unsigned short proto, __wsum sum)
95{
96 return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
97}
98
99/*
100 * this routine is used for miscellaneous IP-like checksums, mainly
101 * in icmp.c
102 */
103
104extern __sum16 ip_compute_csum(const void *buff, int len);
105 43
106#endif /* _BFIN_CHECKSUM_H */ 44#endif
diff --git a/arch/blackfin/lib/Makefile b/arch/blackfin/lib/Makefile
index 635288fc5f54..42c47dc9e12f 100644
--- a/arch/blackfin/lib/Makefile
+++ b/arch/blackfin/lib/Makefile
@@ -5,7 +5,7 @@
5lib-y := \ 5lib-y := \
6 ashldi3.o ashrdi3.o lshrdi3.o \ 6 ashldi3.o ashrdi3.o lshrdi3.o \
7 muldi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o \ 7 muldi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o \
8 checksum.o memcpy.o memset.o memcmp.o memchr.o memmove.o \ 8 memcpy.o memset.o memcmp.o memchr.o memmove.o \
9 strcmp.o strcpy.o strncmp.o strncpy.o \ 9 strcmp.o strcpy.o strncmp.o strncpy.o \
10 umulsi3_highpart.o smulsi3_highpart.o \ 10 umulsi3_highpart.o smulsi3_highpart.o \
11 ins.o outs.o 11 ins.o outs.o
diff --git a/arch/blackfin/lib/checksum.c b/arch/blackfin/lib/checksum.c
deleted file mode 100644
index c62969dc1bbb..000000000000
--- a/arch/blackfin/lib/checksum.c
+++ /dev/null
@@ -1,125 +0,0 @@
1/*
2 * Copyright 2004-2009 Analog Devices Inc.
3 *
4 * Licensed under the GPL-2 or later.
5 *
6 * An implementation of the TCP/IP protocol suite for the LINUX operating
7 * system. INET is implemented using the BSD Socket interface as the
8 * means of communication with the user level.
9 *
10 */
11
12#include <linux/module.h>
13#include <net/checksum.h>
14#include <asm/checksum.h>
15
16#ifdef CONFIG_IP_CHECKSUM_L1
17static unsigned short do_csum(const unsigned char *buff, int len)__attribute__((l1_text));
18#endif
19
20static unsigned short do_csum(const unsigned char *buff, int len)
21{
22 register unsigned long sum = 0;
23 int swappem = 0;
24
25 if (1 & (unsigned long)buff) {
26 sum = *buff << 8;
27 buff++;
28 len--;
29 ++swappem;
30 }
31
32 while (len > 1) {
33 sum += *(unsigned short *)buff;
34 buff += 2;
35 len -= 2;
36 }
37
38 if (len > 0)
39 sum += *buff;
40
41 /* Fold 32-bit sum to 16 bits */
42 while (sum >> 16)
43 sum = (sum & 0xffff) + (sum >> 16);
44
45 if (swappem)
46 sum = ((sum & 0xff00) >> 8) + ((sum & 0x00ff) << 8);
47
48 return sum;
49
50}
51
52/*
53 * This is a version of ip_compute_csum() optimized for IP headers,
54 * which always checksum on 4 octet boundaries.
55 */
56__sum16 ip_fast_csum(unsigned char *iph, unsigned int ihl)
57{
58 return (__force __sum16)~do_csum(iph, ihl * 4);
59}
60EXPORT_SYMBOL(ip_fast_csum);
61
62/*
63 * computes the checksum of a memory block at buff, length len,
64 * and adds in "sum" (32-bit)
65 *
66 * returns a 32-bit number suitable for feeding into itself
67 * or csum_tcpudp_magic
68 *
69 * this function must be called with even lengths, except
70 * for the last fragment, which may be odd
71 *
72 * it's best to have buff aligned on a 32-bit boundary
73 */
74__wsum csum_partial(const void *buff, int len, __wsum sum)
75{
76 /*
77 * Just in case we get nasty checksum data...
78 * Like 0xffff6ec3 in the case of our IPv6 multicast header.
79 * We fold to begin with, as well as at the end.
80 */
81 sum = (sum & 0xffff) + (sum >> 16);
82
83 sum += do_csum(buff, len);
84
85 sum = (sum & 0xffff) + (sum >> 16);
86
87 return sum;
88}
89EXPORT_SYMBOL(csum_partial);
90
91/*
92 * this routine is used for miscellaneous IP-like checksums, mainly
93 * in icmp.c
94 */
95__sum16 ip_compute_csum(const void *buff, int len)
96{
97 return (__force __sum16)~do_csum(buff, len);
98}
99EXPORT_SYMBOL(ip_compute_csum);
100
101/*
102 * copy from fs while checksumming, otherwise like csum_partial
103 */
104
105__wsum
106csum_partial_copy_from_user(const void __user *src, void *dst,
107 int len, __wsum sum, int *csum_err)
108{
109 if (csum_err)
110 *csum_err = 0;
111 memcpy(dst, (__force void *)src, len);
112 return csum_partial(dst, len, sum);
113}
114EXPORT_SYMBOL(csum_partial_copy_from_user);
115
116/*
117 * copy from ds while checksumming, otherwise like csum_partial
118 */
119
120__wsum csum_partial_copy(const void *src, void *dst, int len, __wsum sum)
121{
122 memcpy(dst, src, len);
123 return csum_partial(dst, len, sum);
124}
125EXPORT_SYMBOL(csum_partial_copy);