ipv4: Update parameters for csum_tcpudp_magic to their original types

This patch updates all instances of csum_tcpudp_magic and
csum_tcpudp_nofold to reflect the types that are usually used as the source
inputs.  For example the protocol field is populated based on nexthdr which
is actually an unsigned 8 bit value.  The length is usually populated based
on skb->len which is an unsigned integer.

This addresses an issue in which the IPv6 function csum_ipv6_magic was
generating a checksum using the full 32b of skb->len while
csum_tcpudp_magic was only using the lower 16 bits.  As a result we could
run into issues when attempting to adjust the checksum as there was no
protocol agnostic way to update it.

With this change the value is still truncated as many architectures use
"(len + proto) << 8", however this truncation only occurs for values
greater than 16776960 in length and as such is unlikely to occur as we stop
the inner headers at ~64K in size.

I did have to make a few minor changes in the arm, mn10300, nios2, and
score versions of the function in order to support these changes as they
were either using things such as an OR to combine the protocol and length,
or were using ntohs to convert the length which would have truncated the
value.

I also updated a few spots in terms of whitespace and type differences for
the addresses.  Most of this was just to make sure all of the definitions
were in sync going forward.

Signed-off-by: Alexander Duyck <aduyck@mirantis.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Alexander Duyck 2016-03-11 14:05:34 -08:00 committed by David S. Miller
parent fbd40ea018
commit 01cfbad79a
34 changed files with 106 additions and 150 deletions

View File

@ -13,14 +13,11 @@ extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
* computes the checksum of the TCP/UDP pseudo-header * computes the checksum of the TCP/UDP pseudo-header
* returns a 16-bit checksum, already complemented * returns a 16-bit checksum, already complemented
*/ */
extern __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto, __wsum sum);
unsigned short proto,
__wsum sum);
__wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned short len, unsigned short proto, __u32 len, __u8 proto, __wsum sum);
__wsum sum);
/* /*
* computes the checksum of a memory block at buff, length len, * computes the checksum of a memory block at buff, length len,

View File

@ -42,9 +42,7 @@ static inline unsigned short from64to16(unsigned long x)
* returns a 16-bit checksum, already complemented. * returns a 16-bit checksum, already complemented.
*/ */
__sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto, __wsum sum)
unsigned short proto,
__wsum sum)
{ {
return (__force __sum16)~from64to16( return (__force __sum16)~from64to16(
(__force u64)saddr + (__force u64)daddr + (__force u64)saddr + (__force u64)daddr +
@ -52,9 +50,7 @@ __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
} }
__wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto, __wsum sum)
unsigned short proto,
__wsum sum)
{ {
unsigned long result; unsigned long result;

View File

@ -70,8 +70,8 @@ ip_fast_csum(const void *iph, unsigned int ihl)
* SA [4], DA [4], zeroes [1], Proto[1], TCP Seg(hdr+data) Len [2] * SA [4], DA [4], zeroes [1], Proto[1], TCP Seg(hdr+data) Len [2]
*/ */
static inline __wsum static inline __wsum
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
__asm__ __volatile__( __asm__ __volatile__(
" add.f %0, %0, %1 \n" " add.f %0, %0, %1 \n"

View File

@ -84,10 +84,10 @@ ip_fast_csum(const void *iph, unsigned int ihl)
} }
static inline __wsum static inline __wsum
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
u32 lenprot = len | proto << 16; u32 lenprot = len + proto;
if (__builtin_constant_p(sum) && sum == 0) { if (__builtin_constant_p(sum) && sum == 0) {
__asm__( __asm__(
"adds %0, %1, %2 @ csum_tcpudp_nofold0 \n\t" "adds %0, %1, %2 @ csum_tcpudp_nofold0 \n\t"
@ -121,8 +121,8 @@ csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
* returns a 16-bit checksum, already complemented * returns a 16-bit checksum, already complemented
*/ */
static inline __sum16 static inline __sum16
csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_magic(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum)); return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
} }

View File

@ -111,9 +111,8 @@ static inline __sum16 csum_fold(__wsum sum)
} }
static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto, __wsum sum)
__wsum sum)
{ {
asm(" add %0, %1\n" asm(" add %0, %1\n"
" adc %0, %0, %2\n" " adc %0, %0, %2\n"
@ -132,9 +131,8 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
* returns a 16-bit checksum, already complemented * returns a 16-bit checksum, already complemented
*/ */
static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto, __wsum sum)
__wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
} }

View File

@ -14,8 +14,8 @@
*/ */
static inline __wsum static inline __wsum
__csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, __csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
unsigned int carry; unsigned int carry;

View File

@ -10,8 +10,8 @@
#define _ASM_C6X_CHECKSUM_H #define _ASM_C6X_CHECKSUM_H
static inline __wsum static inline __wsum
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
unsigned long long tmp; unsigned long long tmp;

View File

@ -9,8 +9,8 @@
*/ */
static inline __wsum static inline __wsum
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
__wsum res; __wsum res;
__asm__ ("add.d %2, %0\n\t" __asm__ ("add.d %2, %0\n\t"

View File

@ -11,7 +11,7 @@
*/ */
static inline __wsum static inline __wsum
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned short len, unsigned short proto, __wsum sum) __u32 len, __u8 proto, __wsum sum)
{ {
__wsum res; __wsum res;

View File

@ -63,9 +63,8 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
*/ */
static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto, __wsum sum)
__wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
} }

View File

@ -105,8 +105,8 @@ static inline __sum16 csum_fold(__wsum sum)
* returns a 16-bit checksum, already complemented * returns a 16-bit checksum, already complemented
*/ */
static inline __wsum static inline __wsum
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
asm(" addcc %1,%0,%0,icc0 \n" asm(" addcc %1,%0,%0,icc0 \n"
" addxcc %2,%0,%0,icc0 \n" " addxcc %2,%0,%0,icc0 \n"
@ -120,8 +120,8 @@ csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
} }
static inline __sum16 static inline __sum16
csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_magic(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
} }

View File

@ -38,12 +38,12 @@ __wsum csum_partial_copy_nocheck(const void *src, void *dst,
* returns a 16-bit checksum, already complemented * returns a 16-bit checksum, already complemented
*/ */
#define csum_tcpudp_nofold csum_tcpudp_nofold #define csum_tcpudp_nofold csum_tcpudp_nofold
__wsum csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned short len, unsigned short proto, __wsum sum); __u32 len, __u8 proto, __wsum sum);
#define csum_tcpudp_magic csum_tcpudp_magic #define csum_tcpudp_magic csum_tcpudp_magic
__sum16 csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned short len, unsigned short proto, __wsum sum); __u32 len, __u8 proto, __wsum sum);
#include <asm-generic/checksum.h> #include <asm-generic/checksum.h>

View File

@ -60,18 +60,16 @@ static inline unsigned short from64to16(u64 x)
* computes the checksum of the TCP/UDP pseudo-header * computes the checksum of the TCP/UDP pseudo-header
* returns a 16-bit checksum, already complemented. * returns a 16-bit checksum, already complemented.
*/ */
__sum16 csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned short len, unsigned short proto, __u32 len, __u8 proto, __wsum sum)
__wsum sum)
{ {
return (__force __sum16)~from64to16( return (__force __sum16)~from64to16(
(__force u64)saddr + (__force u64)daddr + (__force u64)saddr + (__force u64)daddr +
(__force u64)sum + ((len + proto) << 8)); (__force u64)sum + ((len + proto) << 8));
} }
__wsum csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned short len, unsigned short proto, __u32 len, __u8 proto, __wsum sum)
__wsum sum)
{ {
u64 result; u64 result;

View File

@ -16,15 +16,11 @@ extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
* Computes the checksum of the TCP/UDP pseudo-header returns a 16-bit * Computes the checksum of the TCP/UDP pseudo-header returns a 16-bit
* checksum, already complemented * checksum, already complemented
*/ */
extern __sum16 csum_tcpudp_magic (__be32 saddr, __be32 daddr, extern __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto, __wsum sum);
unsigned short proto,
__wsum sum);
extern __wsum csum_tcpudp_nofold (__be32 saddr, __be32 daddr, extern __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto, __wsum sum);
unsigned short proto,
__wsum sum);
/* /*
* Computes the checksum of a memory block at buff, length len, * Computes the checksum of a memory block at buff, length len,

View File

@ -34,8 +34,8 @@ from64to16 (unsigned long x)
* returns a 16-bit checksum, already complemented. * returns a 16-bit checksum, already complemented.
*/ */
__sum16 __sum16
csum_tcpudp_magic (__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_magic(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
return (__force __sum16)~from64to16( return (__force __sum16)~from64to16(
(__force u64)saddr + (__force u64)daddr + (__force u64)saddr + (__force u64)daddr +
@ -45,8 +45,8 @@ csum_tcpudp_magic (__be32 saddr, __be32 daddr, unsigned short len,
EXPORT_SYMBOL(csum_tcpudp_magic); EXPORT_SYMBOL(csum_tcpudp_magic);
__wsum __wsum
csum_tcpudp_nofold (__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
unsigned long result; unsigned long result;

View File

@ -114,9 +114,8 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
} }
static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto, __wsum sum)
__wsum sum)
{ {
#if defined(__LITTLE_ENDIAN) #if defined(__LITTLE_ENDIAN)
unsigned long len_proto = (proto + len) << 8; unsigned long len_proto = (proto + len) << 8;
@ -145,9 +144,8 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
* returns a 16-bit checksum, already complemented * returns a 16-bit checksum, already complemented
*/ */
static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto, __wsum sum)
__wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
} }

View File

@ -59,8 +59,7 @@ extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
* returns a 16-bit checksum, already complemented * returns a 16-bit checksum, already complemented
*/ */
static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto,
__wsum sum) __wsum sum)
{ {
unsigned long len_proto = (proto + len) << 8; unsigned long len_proto = (proto + len) << 8;
@ -78,8 +77,8 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
} }
static inline __sum16 static inline __sum16
csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_magic(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum)); return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
} }

View File

@ -16,8 +16,8 @@
*/ */
#define csum_tcpudp_nofold csum_tcpudp_nofold #define csum_tcpudp_nofold csum_tcpudp_nofold
static inline __wsum static inline __wsum
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
__asm__("add %0, %0, %1\n\t" __asm__("add %0, %0, %1\n\t"
"addc %0, %0, %2\n\t" "addc %0, %0, %2\n\t"

View File

@ -160,9 +160,9 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
} }
#define ip_fast_csum ip_fast_csum #define ip_fast_csum ip_fast_csum
static inline __wsum csum_tcpudp_nofold(__be32 saddr, static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
__be32 daddr, unsigned short len, unsigned short proto, __u32 len, __u8 proto,
__wsum sum) __wsum sum)
{ {
__asm__( __asm__(
" .set push # csum_tcpudp_nofold\n" " .set push # csum_tcpudp_nofold\n"

View File

@ -37,16 +37,11 @@ static inline __sum16 csum_fold(__wsum sum)
return (~sum) >> 16; return (~sum) >> 16;
} }
static inline __wsum csum_tcpudp_nofold(unsigned long saddr, static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned long daddr, __u32 len, __u8 proto,
unsigned short len,
unsigned short proto,
__wsum sum) __wsum sum)
{ {
__wsum tmp; __wsum tmp = (__wsum)((len + proto) << 8);
tmp = (__wsum) ntohs(len) << 16;
tmp += (__wsum) proto << 8;
asm( asm(
" add %1,%0 \n" " add %1,%0 \n"
@ -64,10 +59,8 @@ static inline __wsum csum_tcpudp_nofold(unsigned long saddr,
* computes the checksum of the TCP/UDP pseudo-header * computes the checksum of the TCP/UDP pseudo-header
* returns a 16-bit checksum, already complemented * returns a 16-bit checksum, already complemented
*/ */
static inline __sum16 csum_tcpudp_magic(unsigned long saddr, static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned long daddr, __u32 len, __u8 proto,
unsigned short len,
unsigned short proto,
__wsum sum) __wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum)); return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));

View File

@ -45,8 +45,7 @@ static inline __sum16 csum_fold(__wsum sum)
*/ */
#define csum_tcpudp_nofold csum_tcpudp_nofold #define csum_tcpudp_nofold csum_tcpudp_nofold
static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto,
__wsum sum) __wsum sum)
{ {
__asm__ __volatile__( __asm__ __volatile__(
@ -60,7 +59,7 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
"cmpltu r8, %0, %3\n" "cmpltu r8, %0, %3\n"
"add %0, %0, r8\n" /* add carry */ "add %0, %0, r8\n" /* add carry */
: "=r" (sum), "=r" (saddr) : "=r" (sum), "=r" (saddr)
: "r" (daddr), "r" ((ntohs(len) << 16) + (proto * 256)), : "r" (daddr), "r" ((len + proto) << 8),
"0" (sum), "0" (sum),
"1" (saddr) "1" (saddr)
: "r8"); : "r8");
@ -69,8 +68,8 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
} }
static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto, __wsum sum) __wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum)); return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
} }

View File

@ -85,9 +85,8 @@ static inline __sum16 csum_fold(__wsum csum)
} }
static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto, __wsum sum)
__wsum sum)
{ {
__asm__( __asm__(
" add %1, %0, %0\n" " add %1, %0, %0\n"
@ -104,9 +103,8 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
* returns a 16-bit checksum, already complemented * returns a 16-bit checksum, already complemented
*/ */
static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto, __wsum sum)
__wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
} }

View File

@ -91,8 +91,7 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
* returns a 32-bit checksum * returns a 32-bit checksum
*/ */
static inline __wsum static inline __wsum
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len, __u8 proto,
unsigned short len, unsigned short proto,
__wsum sum) __wsum sum)
{ {
__u32 csum = (__force __u32)sum; __u32 csum = (__force __u32)sum;
@ -118,8 +117,7 @@ csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
*/ */
static inline __sum16 static inline __sum16
csum_tcpudp_magic(__be32 saddr, __be32 daddr, csum_tcpudp_magic(__be32 saddr, __be32 daddr, __u32 len, __u8 proto,
unsigned short len, unsigned short proto,
__wsum sum) __wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));

View File

@ -127,10 +127,10 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
} }
static inline __wsum static inline __wsum
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
unsigned long tmp = (ntohs(len) << 16) + proto * 256; unsigned long tmp = (len + proto) << 8;
__asm__ __volatile__( __asm__ __volatile__(
".set volatile\n\t" ".set volatile\n\t"
"add\t%0, %0, %2\n\t" "add\t%0, %0, %2\n\t"
@ -161,8 +161,8 @@ csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
* returns a 16-bit checksum, already complemented * returns a 16-bit checksum, already complemented
*/ */
static inline __sum16 static inline __sum16
csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_magic(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum)); return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
} }

View File

@ -115,8 +115,7 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
} }
static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto,
__wsum sum) __wsum sum)
{ {
#ifdef __LITTLE_ENDIAN__ #ifdef __LITTLE_ENDIAN__
@ -142,8 +141,7 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
* returns a 16-bit checksum, already complemented * returns a 16-bit checksum, already complemented
*/ */
static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto,
__wsum sum) __wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum)); return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));

View File

@ -170,9 +170,8 @@ static inline __sum16 csum_fold(__wsum sum)
} }
static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto, __wsum sum)
__wsum sum)
{ {
__asm__ __volatile__("addcc\t%1, %0, %0\n\t" __asm__ __volatile__("addcc\t%1, %0, %0\n\t"
"addxcc\t%2, %0, %0\n\t" "addxcc\t%2, %0, %0\n\t"
@ -190,9 +189,8 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
* returns a 16-bit checksum, already complemented * returns a 16-bit checksum, already complemented
*/ */
static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto, __wsum sum)
__wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
} }

View File

@ -96,8 +96,7 @@ static inline __sum16 csum_fold(__wsum sum)
} }
static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned int len, __u32 len, __u8 proto,
unsigned short proto,
__wsum sum) __wsum sum)
{ {
__asm__ __volatile__( __asm__ __volatile__(
@ -116,8 +115,7 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
* returns a 16-bit checksum, already complemented * returns a 16-bit checksum, already complemented
*/ */
static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto,
__wsum sum) __wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));

View File

@ -20,8 +20,8 @@
*/ */
static inline __wsum static inline __wsum
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
__asm__( __asm__(
"add.a %0, %1, %2\n" "add.a %0, %1, %2\n"

View File

@ -112,8 +112,7 @@ static inline __sum16 csum_fold(__wsum sum)
} }
static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto,
__wsum sum) __wsum sum)
{ {
asm("addl %1, %0 ;\n" asm("addl %1, %0 ;\n"
@ -131,8 +130,7 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
* returns a 16-bit checksum, already complemented * returns a 16-bit checksum, already complemented
*/ */
static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto,
__wsum sum) __wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum)); return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));

View File

@ -84,8 +84,8 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
* 32bit unfolded. * 32bit unfolded.
*/ */
static inline __wsum static inline __wsum
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
asm(" addl %1, %0\n" asm(" addl %1, %0\n"
" adcl %2, %0\n" " adcl %2, %0\n"
@ -110,8 +110,8 @@ csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
* complemented and ready to be filled in. * complemented and ready to be filled in.
*/ */
static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto, __wsum sum) __wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum)); return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
} }

View File

@ -87,8 +87,8 @@ static inline __sum16 csum_fold(__wsum sum)
* 32bit unfolded. * 32bit unfolded.
*/ */
static inline __wsum static inline __wsum
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
asm(" addl %1, %0\n" asm(" addl %1, %0\n"
" adcl %2, %0\n" " adcl %2, %0\n"
@ -104,9 +104,8 @@ csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
* returns a 16-bit checksum, already complemented * returns a 16-bit checksum, already complemented
*/ */
static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto, __wsum sum)
__wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
} }

View File

@ -123,9 +123,8 @@ static __inline__ __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
} }
static __inline__ __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, static __inline__ __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto, __wsum sum)
__wsum sum)
{ {
#ifdef __XTENSA_EL__ #ifdef __XTENSA_EL__
@ -157,9 +156,8 @@ static __inline__ __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
* returns a 16-bit checksum, already complemented * returns a 16-bit checksum, already complemented
*/ */
static __inline__ __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, static __inline__ __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto,
unsigned short proto, __wsum sum)
__wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
} }

View File

@ -65,14 +65,14 @@ static inline __sum16 csum_fold(__wsum csum)
* returns a 16-bit checksum, already complemented * returns a 16-bit checksum, already complemented
*/ */
extern __wsum extern __wsum
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum); __u8 proto, __wsum sum);
#endif #endif
#ifndef csum_tcpudp_magic #ifndef csum_tcpudp_magic
static inline __sum16 static inline __sum16
csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len, csum_tcpudp_magic(__be32 saddr, __be32 daddr, __u32 len,
unsigned short proto, __wsum sum) __u8 proto, __wsum sum)
{ {
return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum)); return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
} }

View File

@ -191,9 +191,7 @@ static inline u32 from64to32(u64 x)
} }
__wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
unsigned short len, __u32 len, __u8 proto, __wsum sum)
unsigned short proto,
__wsum sum)
{ {
unsigned long long s = (__force u32)sum; unsigned long long s = (__force u32)sum;