1129198Scognet/*-
2129198Scognet * Copyright (c) 1990 The Regents of the University of California.
3129198Scognet * All rights reserved.
4129198Scognet *
5129198Scognet * Redistribution and use in source and binary forms, with or without
6129198Scognet * modification, are permitted provided that the following conditions
7129198Scognet * are met:
8129198Scognet * 1. Redistributions of source code must retain the above copyright
9129198Scognet *    notice, this list of conditions and the following disclaimer.
10129198Scognet * 2. Redistributions in binary form must reproduce the above copyright
11129198Scognet *    notice, this list of conditions and the following disclaimer in the
12129198Scognet *    documentation and/or other materials provided with the distribution.
13129198Scognet * 3. All advertising materials mentioning features or use of this software
14129198Scognet *    must display the following acknowledgement:
15129198Scognet *	This product includes software developed by the University of
16129198Scognet *	California, Berkeley and its contributors.
17129198Scognet * 4. Neither the name of the University nor the names of its contributors
18129198Scognet *    may be used to endorse or promote products derived from this software
19129198Scognet *    without specific prior written permission.
20129198Scognet *
21129198Scognet * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22129198Scognet * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23129198Scognet * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24129198Scognet * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25129198Scognet * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26129198Scognet * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27129198Scognet * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28129198Scognet * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29129198Scognet * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30129198Scognet * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31129198Scognet * SUCH DAMAGE.
32129198Scognet *
33129198Scognet *	from tahoe:	in_cksum.c	1.2	86/01/05
34129198Scognet *	from:		@(#)in_cksum.c	1.3 (Berkeley) 1/19/91
35129198Scognet *	from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp
36129198Scognet * $FreeBSD: releng/10.3/sys/arm/include/in_cksum.h 236992 2012-06-13 05:02:51Z imp $
37129198Scognet */
38129198Scognet
39129198Scognet#ifndef _MACHINE_IN_CKSUM_H_
40129198Scognet#define	_MACHINE_IN_CKSUM_H_	1
41129198Scognet
42129198Scognet#include <sys/cdefs.h>
43129198Scognet
44129198Scognet#ifdef _KERNEL
45129198Scognetu_short in_cksum(struct mbuf *m, int len);
46129198Scognetu_short in_addword(u_short sum, u_short b);
47129198Scognetu_short in_cksum_skip(struct mbuf *m, int len, int skip);
48146594Scognetu_int do_cksum(const void *, int);
49235941Sbz#if defined(IPVERSION) && (IPVERSION == 4)
50156520Scognetu_int in_cksum_hdr(const struct ip *);
51235941Sbz#endif
52146594Scognet
53150858Scognetstatic __inline u_short
54150858Scognetin_pseudo(u_int sum, u_int b, u_int c)
55150858Scognet{
56150858Scognet	__asm __volatile("adds %0, %0, %1\n"
57150858Scognet	    		"adcs %0, %0, %2\n"
58150858Scognet			"adc %0, %0, #0\n"
59236992Simp			: "+r" (sum)
60150858Scognet			: "r" (b), "r" (c));
61150858Scognet	sum = (sum & 0xffff) + (sum >> 16);
62150858Scognet	if (sum > 0xffff)
63150858Scognet		sum -= 0xffff;
64150858Scognet	return (sum);
65150858Scognet}
66150858Scognet
67129198Scognet#endif /* _KERNEL */
68129198Scognet#endif /* _MACHINE_IN_CKSUM_H_ */
69