cregit-Linux how code gets into the kernel

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

PersonTokensPropCommitsCommitProp
Martin Schwidefsky2951.79%350.00%
Linus Torvalds (pre-git)1628.57%116.67%
Linus Torvalds814.29%116.67%
Al Viro35.36%116.67%
Total56100.00%6100.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

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)3968.42%116.67%
Linus Torvalds712.28%116.67%
Heiko Carstens58.77%116.67%
Al Viro47.02%116.67%
Martin Schwidefsky11.75%116.67%
Andrew Morton11.75%116.67%
Total57100.00%6100.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

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)3585.37%125.00%
Al Viro49.76%125.00%
Martin Schwidefsky24.88%250.00%
Total41100.00%4100.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

PersonTokensPropCommitsCommitProp
Heiko Carstens2760.00%120.00%
Linus Torvalds (pre-git)1226.67%120.00%
Al Viro48.89%120.00%
Linus Torvalds12.22%120.00%
Martin Schwidefsky12.22%120.00%
Total45100.00%5100.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

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)1445.16%120.00%
Martin Schwidefsky1032.26%240.00%
Linus Torvalds412.90%120.00%
Al Viro39.68%120.00%
Total31100.00%5100.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

PersonTokensPropCommitsCommitProp
Heiko Carstens7375.26%120.00%
Linus Torvalds (pre-git)1717.53%120.00%
Al Viro44.12%120.00%
Alexander Duyck22.06%120.00%
Martin Schwidefsky11.03%120.00%
Total97100.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)3282.05%125.00%
Al Viro410.26%125.00%
Alexander Duyck25.13%125.00%
Martin Schwidefsky12.56%125.00%
Total39100.00%4100.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)2485.71%133.33%
Al Viro310.71%133.33%
Martin Schwidefsky13.57%133.33%
Total28100.00%3100.00%

#endif /* _S390_CHECKSUM_H */

Overall Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)20649.64%16.67%
Heiko Carstens10725.78%426.67%
Martin Schwidefsky4611.08%320.00%
Al Viro296.99%16.67%
Linus Torvalds215.06%320.00%
Alexander Duyck40.96%16.67%
Andrew Morton10.24%16.67%
Greg Kroah-Hartman10.24%16.67%
Total415100.00%15100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.