xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zio_checksum.h (revision 65a89a64c60f3061bbe2381edaacc81660af9a95)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_ZIO_CHECKSUM_H
28 #define	_SYS_ZIO_CHECKSUM_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/zio.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * Signature for checksum functions.
40  */
41 typedef void zio_checksum_t(const void *data, uint64_t size, zio_cksum_t *zcp);
42 
43 /*
44  * Information about each checksum function.
45  */
46 typedef struct zio_checksum_info {
47 	zio_checksum_t	*ci_func[2]; /* checksum function for each byteorder */
48 	int		ci_correctable;	/* number of correctable bits	*/
49 	int		ci_zbt;		/* uses zio block tail?	*/
50 	char		*ci_name;	/* descriptive name */
51 } zio_checksum_info_t;
52 
53 extern zio_checksum_info_t zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS];
54 
55 /*
56  * Checksum routines.
57  */
58 extern zio_checksum_t fletcher_2_native;
59 extern zio_checksum_t fletcher_4_native;
60 
61 extern zio_checksum_t fletcher_2_byteswap;
62 extern zio_checksum_t fletcher_4_byteswap;
63 
64 extern zio_checksum_t zio_checksum_SHA256;
65 
66 extern void zio_checksum(uint_t checksum, zio_cksum_t *zcp,
67     void *data, uint64_t size);
68 extern int zio_checksum_error(zio_t *zio);
69 
70 #ifdef	__cplusplus
71 }
72 #endif
73 
74 #endif	/* _SYS_ZIO_CHECKSUM_H */
75