more changes on original files
[linux-2.4.git] / arch / s390x / lib / checksum.c
1 /*
2  *  arch/s390/lib/checksum.c
3  *    S390 fast network checksum routines
4  *
5  *  S390 version
6  *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
7  *    Author(s): Ulrich Hild        (first version),
8  *               Martin Schwidefsky (schwidefsky@de.ibm.com),
9  *               Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
10  *
11  * This file contains network checksum routines
12  */
13  
14 #include <linux/string.h>
15 #include <linux/types.h>
16 #include <asm/uaccess.h>
17 #include <asm/byteorder.h>
18 #include <asm/checksum.h>
19
20 /*
21  * computes a partial checksum, e.g. for TCP/UDP fragments
22  */
23 unsigned int
24 csum_partial (const unsigned char *buff, int len, unsigned int sum)
25 {
26           /*
27            * Experiments with ethernet and slip connections show that buff
28            * is aligned on either a 2-byte or 4-byte boundary.
29            */
30         __asm__ __volatile__ (
31                 "    lgr  2,%1\n"    /* address in gpr 2 */
32                 "    lgfr 3,%2\n"    /* length in gpr 3 */
33                 "0:  cksm %0,2\n"    /* do checksum on longs */
34                 "    jo   0b\n"
35                 : "+&d" (sum)
36                 : "d" (buff), "d" (len)
37                 : "cc", "2", "3" );
38         return sum;
39 }
40