cregit-Linux how code gets into the kernel

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

PersonTokensPropCommitsCommitProp
Russell King27100.00%1100.00%
Total27100.00%1100.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

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)2268.75%250.00%
Al Viro618.75%125.00%
Russell King412.50%125.00%
Total32100.00%4100.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

PersonTokensPropCommitsCommitProp
Russell King3752.86%120.00%
Linus Torvalds (pre-git)1927.14%240.00%
Al Viro1115.71%120.00%
Alexander Duyck34.29%120.00%
Total70100.00%5100.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

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)1948.72%240.00%
Russell King1230.77%120.00%
Al Viro615.38%120.00%
Alexander Duyck25.13%120.00%
Total39100.00%5100.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

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)2589.29%266.67%
Al Viro310.71%133.33%
Total28100.00%3100.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

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)4486.27%350.00%
Al Viro47.84%116.67%
Linus Torvalds23.92%116.67%
Alexander Duyck11.96%116.67%
Total51100.00%6100.00%

#endif

Overall Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)21159.94%430.77%
Russell King8223.30%323.08%
Al Viro4813.64%215.38%
Alexander Duyck61.70%215.38%
David Vrabel30.85%17.69%
Linus Torvalds20.57%17.69%
Total352100.00%13100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.