Release 4.11 arch/arm/include/asm/checksum.h
/*
* arch/arm/include/asm/checksum.h
*
* IP checksum routines
*
* Copyright (C) Original authors of ../asm-i386/checksum.h
* Copyright (C) 1996-1999 Russell King
*/
#ifndef __ASM_ARM_CHECKSUM_H
#define __ASM_ARM_CHECKSUM_H
#include <linux/in6.h>
/*
* computes the checksum of a memory block at buff, length len,
* and adds in "sum" (32-bit)
*
* returns a 32-bit number suitable for feeding into itself
* or csum_tcpudp_magic
*
* this function must be called with even lengths, except
* for the last fragment, which may be odd
*
* it's best to have buff aligned on a 32-bit boundary
*/
__wsum csum_partial(const void *buff, int len, __wsum sum);
/*
* the same as csum_partial, but copies from src while it
* checksums, and handles user-space pointer exceptions correctly, when needed.
*
* here even more important to align src and dst on a 32-bit (or even
* better 64-bit) boundary
*/
__wsum
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);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Russell King | 27 | 100.00% | 1 | 100.00% |
Total | 27 | 100.00% | 1 | 100.00% |
/*
* 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 tmp1;
__wsum sum;
__asm__ __volatile__(
"ldr %0, [%1], #4 @ ip_fast_csum \n\
ldr %3, [%1], #4 \n\
sub %2, %2, #5 \n\
adds %0, %0, %3 \n\
ldr %3, [%1], #4 \n\
adcs %0, %0, %3 \n\
ldr %3, [%1], #4 \n\
1: adcs %0, %0, %3 \n\
ldr %3, [%1], #4 \n\
tst %2, #15 @ do this carefully \n\
subne %2, %2, #1 @ without destroying \n\
bne 1b @ the carry flag \n\
adcs %0, %0, %3 \n\
adc %0, %0, #0"
: "=r" (sum), "=r" (iph), "=r" (ihl), "=r" (tmp1)
: "1" (iph), "2" (ihl)
: "cc", "memory");
return csum_fold(sum);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 22 | 68.75% | 2 | 50.00% |
Al Viro | 6 | 18.75% | 1 | 25.00% |
Russell King | 4 | 12.50% | 1 | 25.00% |
Total | 32 | 100.00% | 4 | 100.00% |
static inline __wsum
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
__u8 proto, __wsum sum)
{
u32 lenprot = len + proto;
if (__builtin_constant_p(sum) && sum == 0) {
__asm__(
"adds %0, %1, %2 @ csum_tcpudp_nofold0 \n\t"
#ifdef __ARMEB__
"adcs %0, %0, %3 \n\t"
#else
"adcs %0, %0, %3, ror #8 \n\t"
#endif
"adc %0, %0, #0"
: "=&r" (sum)
: "r" (daddr), "r" (saddr), "r" (lenprot)
: "cc");
} else {
__asm__(
"adds %0, %1, %2 @ csum_tcpudp_nofold \n\t"
"adcs %0, %0, %3 \n\t"
#ifdef __ARMEB__
"adcs %0, %0, %4 \n\t"
#else
"adcs %0, %0, %4, ror #8 \n\t"
#endif
"adc %0, %0, #0"
: "=&r"(sum)
: "r" (sum), "r" (daddr), "r" (saddr), "r" (lenprot)
: "cc");
}
return sum;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Russell King | 37 | 52.86% | 1 | 20.00% |
Linus Torvalds (pre-git) | 19 | 27.14% | 2 | 40.00% |
Al Viro | 11 | 15.71% | 1 | 20.00% |
Alexander Duyck | 3 | 4.29% | 1 | 20.00% |
Total | 70 | 100.00% | 5 | 100.00% |
/*
* computes the checksum of the TCP/UDP pseudo-header
* returns a 16-bit checksum, already complemented
*/
static inline __sum16
csum_tcpudp_magic(__be32 saddr, __be32 daddr, __u32 len,
__u8 proto, __wsum sum)
{
return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 19 | 48.72% | 2 | 40.00% |
Russell King | 12 | 30.77% | 1 | 20.00% |
Al Viro | 6 | 15.38% | 1 | 20.00% |
Alexander Duyck | 2 | 5.13% | 1 | 20.00% |
Total | 39 | 100.00% | 5 | 100.00% |
/*
* this routine is used for miscellaneous IP-like checksums, mainly
* in icmp.c
*/
static inline __sum16
ip_compute_csum(const void *buff, int len)
{
return csum_fold(csum_partial(buff, len, 0));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 25 | 89.29% | 2 | 66.67% |
Al Viro | 3 | 10.71% | 1 | 33.33% |
Total | 28 | 100.00% | 3 | 100.00% |
#define _HAVE_ARCH_IPV6_CSUM
extern __wsum
__csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr, __be32 len,
__be32 proto, __wsum sum);
static inline __sum16
csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
__u32 len, __u8 proto, __wsum sum)
{
return csum_fold(__csum_ipv6_magic(saddr, daddr, htonl(len),
htonl(proto), sum));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 44 | 86.27% | 3 | 50.00% |
Al Viro | 4 | 7.84% | 1 | 16.67% |
Linus Torvalds | 2 | 3.92% | 1 | 16.67% |
Alexander Duyck | 1 | 1.96% | 1 | 16.67% |
Total | 51 | 100.00% | 6 | 100.00% |
#endif
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 211 | 59.94% | 4 | 30.77% |
Russell King | 82 | 23.30% | 3 | 23.08% |
Al Viro | 48 | 13.64% | 2 | 15.38% |
Alexander Duyck | 6 | 1.70% | 2 | 15.38% |
David Vrabel | 3 | 0.85% | 1 | 7.69% |
Linus Torvalds | 2 | 0.57% | 1 | 7.69% |
Total | 352 | 100.00% | 13 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.