Release 4.14 arch/s390/include/asm/checksum.h
/* SPDX-License-Identifier: GPL-2.0 */
/*
* S390 fast network checksum routines
*
* S390 version
* Copyright IBM Corp. 1999
* Author(s): Ulrich Hild (first version)
* Martin Schwidefsky (heavily optimized CKSM version)
* D.J. Barrow (third attempt)
*/
#ifndef _S390_CHECKSUM_H
#define _S390_CHECKSUM_H
#include <linux/uaccess.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
*/
static inline __wsum
csum_partial(const void *buff, int len, __wsum sum)
{
register unsigned long reg2 asm("2") = (unsigned long) buff;
register unsigned long reg3 asm("3") = (unsigned long) len;
asm volatile(
"0: cksm %0,%1\n" /* do checksum on longs */
" jo 0b\n"
: "+d" (sum), "+d" (reg2), "+d" (reg3) : : "cc", "memory");
return sum;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Martin Schwidefsky | 29 | 51.79% | 3 | 50.00% |
Linus Torvalds (pre-git) | 16 | 28.57% | 1 | 16.67% |
Linus Torvalds | 8 | 14.29% | 1 | 16.67% |
Al Viro | 3 | 5.36% | 1 | 16.67% |
Total | 56 | 100.00% | 6 | 100.00% |
/*
* the same as csum_partial_copy, but copies from user space.
*
* here even more important to align src and dst on a 32-bit (or even
* better 64-bit) boundary
*
* Copy from userspace and compute checksum.
*/
static inline __wsum
csum_partial_copy_from_user(const void __user *src, void *dst,
int len, __wsum sum,
int *err_ptr)
{
if (unlikely(copy_from_user(dst, src, len)))
*err_ptr = -EFAULT;
return csum_partial(dst, len, sum);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 39 | 68.42% | 1 | 16.67% |
Linus Torvalds | 7 | 12.28% | 1 | 16.67% |
Heiko Carstens | 5 | 8.77% | 1 | 16.67% |
Al Viro | 4 | 7.02% | 1 | 16.67% |
Martin Schwidefsky | 1 | 1.75% | 1 | 16.67% |
Andrew Morton | 1 | 1.75% | 1 | 16.67% |
Total | 57 | 100.00% | 6 | 100.00% |
static inline __wsum
csum_partial_copy_nocheck (const void *src, void *dst, int len, __wsum sum)
{
memcpy(dst,src,len);
return csum_partial(dst, len, sum);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 35 | 85.37% | 1 | 25.00% |
Al Viro | 4 | 9.76% | 1 | 25.00% |
Martin Schwidefsky | 2 | 4.88% | 2 | 50.00% |
Total | 41 | 100.00% | 4 | 100.00% |
/*
* Fold a partial checksum without adding pseudo headers
*/
static inline __sum16 csum_fold(__wsum sum)
{
u32 csum = (__force u32) sum;
csum += (csum >> 16) + (csum << 16);
csum >>= 16;
return (__force __sum16) ~csum;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Heiko Carstens | 27 | 60.00% | 1 | 20.00% |
Linus Torvalds (pre-git) | 12 | 26.67% | 1 | 20.00% |
Al Viro | 4 | 8.89% | 1 | 20.00% |
Linus Torvalds | 1 | 2.22% | 1 | 20.00% |
Martin Schwidefsky | 1 | 2.22% | 1 | 20.00% |
Total | 45 | 100.00% | 5 | 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)
{
return csum_fold(csum_partial(iph, ihl*4, 0));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 14 | 45.16% | 1 | 20.00% |
Martin Schwidefsky | 10 | 32.26% | 2 | 40.00% |
Linus Torvalds | 4 | 12.90% | 1 | 20.00% |
Al Viro | 3 | 9.68% | 1 | 20.00% |
Total | 31 | 100.00% | 5 | 100.00% |
/*
* computes the checksum of the TCP/UDP pseudo-header
* returns a 32-bit checksum
*/
static inline __wsum
csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len, __u8 proto,
__wsum sum)
{
__u32 csum = (__force __u32)sum;
csum += (__force __u32)saddr;
if (csum < (__force __u32)saddr)
csum++;
csum += (__force __u32)daddr;
if (csum < (__force __u32)daddr)
csum++;
csum += len + proto;
if (csum < len + proto)
csum++;
return (__force __wsum)csum;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Heiko Carstens | 73 | 75.26% | 1 | 20.00% |
Linus Torvalds (pre-git) | 17 | 17.53% | 1 | 20.00% |
Al Viro | 4 | 4.12% | 1 | 20.00% |
Alexander Duyck | 2 | 2.06% | 1 | 20.00% |
Martin Schwidefsky | 1 | 1.03% | 1 | 20.00% |
Total | 97 | 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) | 32 | 82.05% | 1 | 25.00% |
Al Viro | 4 | 10.26% | 1 | 25.00% |
Alexander Duyck | 2 | 5.13% | 1 | 25.00% |
Martin Schwidefsky | 1 | 2.56% | 1 | 25.00% |
Total | 39 | 100.00% | 4 | 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) | 24 | 85.71% | 1 | 33.33% |
Al Viro | 3 | 10.71% | 1 | 33.33% |
Martin Schwidefsky | 1 | 3.57% | 1 | 33.33% |
Total | 28 | 100.00% | 3 | 100.00% |
#endif /* _S390_CHECKSUM_H */
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 206 | 49.64% | 1 | 6.67% |
Heiko Carstens | 107 | 25.78% | 4 | 26.67% |
Martin Schwidefsky | 46 | 11.08% | 3 | 20.00% |
Al Viro | 29 | 6.99% | 1 | 6.67% |
Linus Torvalds | 21 | 5.06% | 3 | 20.00% |
Alexander Duyck | 4 | 0.96% | 1 | 6.67% |
Andrew Morton | 1 | 0.24% | 1 | 6.67% |
Greg Kroah-Hartman | 1 | 0.24% | 1 | 6.67% |
Total | 415 | 100.00% | 15 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.