Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 48881
b: refs/heads/master
c: 7ef416c
h: refs/heads/master
i:
  48879: 2ef361e
v: v3
  • Loading branch information
Russell King authored and Russell King committed Feb 6, 2007
1 parent cd39077 commit 31a2c60
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 39 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 10c03f69680e9e2acd8a9409a230aef37295ac49
refs/heads/master: 7ef416c4b878685a419a3b2f133ab5e7283f96b0
56 changes: 18 additions & 38 deletions trunk/include/asm-arm/checksum.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,28 @@ csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
__wsum
csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);

/*
* Fold a partial checksum without adding pseudo headers
*/
static inline __sum16 csum_fold(__wsum sum)
{
__asm__(
"add %0, %1, %1, ror #16 @ csum_fold"
: "=r" (sum)
: "r" (sum)
: "cc");
return (__force __sum16)(~(__force u32)sum >> 16);
}

/*
* This is a version of ip_compute_csum() optimized for IP headers,
* which always checksum on 4 octet boundaries.
*/
static inline __sum16
ip_fast_csum(const void *iph, unsigned int ihl)
{
unsigned int sum, tmp1;
unsigned int tmp1;
__wsum sum;

__asm__ __volatile__(
"ldr %0, [%1], #4 @ ip_fast_csum \n\
Expand All @@ -62,29 +76,11 @@ ip_fast_csum(const void *iph, unsigned int ihl)
subne %2, %2, #1 @ without destroying \n\
bne 1b @ the carry flag \n\
adcs %0, %0, %3 \n\
adc %0, %0, #0 \n\
adds %0, %0, %0, lsl #16 \n\
addcs %0, %0, #0x10000 \n\
mvn %0, %0 \n\
mov %0, %0, lsr #16"
adc %0, %0, #0"
: "=r" (sum), "=r" (iph), "=r" (ihl), "=r" (tmp1)
: "1" (iph), "2" (ihl)
: "cc", "memory");
return (__force __sum16)sum;
}

/*
* Fold a partial checksum without adding pseudo headers
*/
static inline __sum16 csum_fold(__wsum sum)
{
__asm__(
"adds %0, %1, %1, lsl #16 @ csum_fold \n\
addcs %0, %0, #0x10000"
: "=r" (sum)
: "r" (sum)
: "cc");
return (__force __sum16)(~(__force u32)sum >> 16);
return csum_fold(sum);
}

static inline __wsum
Expand Down Expand Up @@ -114,23 +110,7 @@ static inline __sum16
csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
unsigned short proto, __wsum sum)
{
__asm__(
"adds %0, %1, %2 @ csum_tcpudp_magic \n\
adcs %0, %0, %3 \n"
#ifdef __ARMEB__
"adcs %0, %0, %4 \n"
#else
"adcs %0, %0, %4, lsl #8 \n"
#endif
"adcs %0, %0, %5 \n\
adc %0, %0, #0 \n\
adds %0, %0, %0, lsl #16 \n\
addcs %0, %0, #0x10000 \n\
mvn %0, %0"
: "=&r"(sum)
: "r" (sum), "r" (daddr), "r" (saddr), "r" (len), "Ir" (htons(proto))
: "cc");
return (__force __sum16)((__force u32)sum >> 16);
return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
}


Expand Down

0 comments on commit 31a2c60

Please sign in to comment.